From 14ae070250523c21dd90a82cbd70685694bbbb87 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:39:01 +0000 Subject: [PATCH 1/6] chore(internal): version bump (#89) --- .../src/main/kotlin/com/withorb/api/core/ClientOptions.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 814dfc81f..dd8f425ce 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 @@ -11,6 +11,7 @@ import java.time.Clock class ClientOptions private constructor( + private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @@ -49,7 +50,7 @@ private constructor( @JvmSynthetic internal fun from(clientOptions: ClientOptions) = apply { - httpClient = clientOptions.httpClient + httpClient = clientOptions.originalHttpClient jsonMapper = clientOptions.jsonMapper clock = clientOptions.clock baseUrl = clientOptions.baseUrl @@ -148,6 +149,7 @@ private constructor( this.queryParams.forEach(queryParams::replaceValues) return ClientOptions( + httpClient!!, RetryingHttpClient.builder() .httpClient(httpClient!!) .clock(clock) From 6a7b7b8e059d6d1257d0e256818f01f5778a4636 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 22:10:39 +0000 Subject: [PATCH 2/6] feat(api): api update (#90) --- .stats.yml | 2 +- .../com/withorb/api/core/ClientOptions.kt | 15 +++--- .../com/withorb/api/core/PhantomReachable.kt | 46 +++++++++++++++++++ .../http/PhantomReachableClosingHttpClient.kt | 21 +++++++++ .../api/models/EventVolumeListParams.kt | 42 ++++++++--------- .../api/models/InvoiceFetchUpcomingParams.kt | 9 ++-- .../withorb/api/core/PhantomReachableTest.kt | 27 +++++++++++ .../api/models/EventVolumeListParamsTest.kt | 12 +++-- .../models/InvoiceFetchUpcomingParamsTest.kt | 3 +- .../blocking/events/VolumeServiceTest.kt | 2 +- 10 files changed, 140 insertions(+), 39 deletions(-) create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachable.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingHttpClient.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/core/PhantomReachableTest.kt diff --git a/.stats.yml b/.stats.yml index 95634a7b0..2058bd1c6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 95 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-96918acc38b19b3897bf9e90efacbe214997b801f29f00fa246521c8a48f7cc0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-1a0cb9f84cf6b6342b82c87ecdcba968405aac1dfb0c78eaf055a44fe15cab2c.yml 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 dd8f425ce..1eac0192b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ListMultimap import com.withorb.api.core.http.HttpClient +import com.withorb.api.core.http.PhantomReachableClosingHttpClient import com.withorb.api.core.http.RetryingHttpClient import java.time.Clock @@ -150,12 +151,14 @@ private constructor( return ClientOptions( httpClient!!, - RetryingHttpClient.builder() - .httpClient(httpClient!!) - .clock(clock) - .maxRetries(maxRetries) - .idempotencyHeader("Idempotency-Key") - .build(), + PhantomReachableClosingHttpClient( + RetryingHttpClient.builder() + .httpClient(httpClient!!) + .clock(clock) + .maxRetries(maxRetries) + .idempotencyHeader("Idempotency-Key") + .build() + ), jsonMapper ?: jsonMapper(), clock, baseUrl, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachable.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachable.kt new file mode 100644 index 000000000..9b99f85a6 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/PhantomReachable.kt @@ -0,0 +1,46 @@ +@file:JvmName("PhantomReachable") + +package com.withorb.api.core + +import com.withorb.api.errors.OrbException +import java.lang.reflect.InvocationTargetException + +/** + * Closes [closeable] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable) { + check(observed !== closeable) { + "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" + } + closeWhenPhantomReachable?.let { it(observed, closeable::close) } +} + +private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy { + try { + val cleanerClass = Class.forName("java.lang.ref.Cleaner") + val cleanerCreate = cleanerClass.getMethod("create") + val cleanerRegister = + cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) + val cleanerObject = cleanerCreate.invoke(null); + + { observed, closeable -> + try { + cleanerRegister.invoke(cleanerObject, observed, Runnable { closeable.close() }) + } catch (e: ReflectiveOperationException) { + if (e is InvocationTargetException) { + when (val cause = e.cause) { + is RuntimeException, + is Error -> throw cause + } + } + throw OrbException("Unexpected reflective invocation failure", e) + } + } + } catch (e: ReflectiveOperationException) { + // We're running Java 8, which has no Cleaner. + null + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingHttpClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingHttpClient.kt new file mode 100644 index 000000000..287dba554 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingHttpClient.kt @@ -0,0 +1,21 @@ +package com.withorb.api.core.http + +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.closeWhenPhantomReachable +import java.util.concurrent.CompletableFuture + +internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { + init { + closeWhenPhantomReachable(this, httpClient) + } + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse = + httpClient.execute(request, requestOptions) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions + ): CompletableFuture = httpClient.executeAsync(request, requestOptions) + + override fun close() = httpClient.close() +} 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 88d2e5ee2..efcc767b1 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 @@ -12,33 +12,33 @@ import java.util.Optional class EventVolumeListParams constructor( + private val timeframeStart: OffsetDateTime, private val cursor: String?, private val limit: Long?, private val timeframeEnd: OffsetDateTime?, - private val timeframeStart: OffsetDateTime?, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { + fun timeframeStart(): OffsetDateTime = timeframeStart + fun cursor(): Optional = Optional.ofNullable(cursor) fun limit(): Optional = Optional.ofNullable(limit) fun timeframeEnd(): Optional = Optional.ofNullable(timeframeEnd) - fun timeframeStart(): Optional = Optional.ofNullable(timeframeStart) - @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() + this.timeframeStart.let { + params.put("timeframe_start", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) + } this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } this.timeframeEnd?.let { params.put("timeframe_end", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) } - this.timeframeStart?.let { - params.put("timeframe_start", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) - } params.putAll(additionalQueryParams) return params.toUnmodifiable() } @@ -54,15 +54,15 @@ constructor( return true } - return /* spotless:off */ other is EventVolumeListParams && this.cursor == other.cursor && this.limit == other.limit && this.timeframeEnd == other.timeframeEnd && this.timeframeStart == other.timeframeStart && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is EventVolumeListParams && this.timeframeStart == other.timeframeStart && this.cursor == other.cursor && this.limit == other.limit && this.timeframeEnd == other.timeframeEnd && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(cursor, limit, timeframeEnd, timeframeStart, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(timeframeStart, cursor, limit, timeframeEnd, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = - "EventVolumeListParams{cursor=$cursor, limit=$limit, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "EventVolumeListParams{timeframeStart=$timeframeStart, cursor=$cursor, limit=$limit, timeframeEnd=$timeframeEnd, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,23 +74,32 @@ constructor( @NoAutoDetect class Builder { + private var timeframeStart: OffsetDateTime? = null private var cursor: String? = null private var limit: Long? = null private var timeframeEnd: OffsetDateTime? = null - private var timeframeStart: OffsetDateTime? = null private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() @JvmSynthetic internal fun from(eventVolumeListParams: EventVolumeListParams) = apply { + this.timeframeStart = eventVolumeListParams.timeframeStart this.cursor = eventVolumeListParams.cursor this.limit = eventVolumeListParams.limit this.timeframeEnd = eventVolumeListParams.timeframeEnd - this.timeframeStart = eventVolumeListParams.timeframeStart additionalQueryParams(eventVolumeListParams.additionalQueryParams) additionalHeaders(eventVolumeListParams.additionalHeaders) } + /** + * The start of the timeframe, inclusive, in which to return event volume. All datetime + * values are converted to UTC time. If the specified time isn't hour-aligned, the response + * includes the event volume count for the hour the time falls in. + */ + fun timeframeStart(timeframeStart: OffsetDateTime) = apply { + this.timeframeStart = timeframeStart + } + /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the * initial request. @@ -108,15 +117,6 @@ constructor( */ fun timeframeEnd(timeframeEnd: OffsetDateTime) = apply { this.timeframeEnd = timeframeEnd } - /** - * The start of the timeframe, inclusive, in which to return event volume. All datetime - * values are converted to UTC time. If the specified time isn't hour-aligned, the response - * includes the event volume count for the hour the time falls in. - */ - fun timeframeStart(timeframeStart: OffsetDateTime) = apply { - this.timeframeStart = timeframeStart - } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() putAllQueryParams(additionalQueryParams) @@ -159,10 +159,10 @@ constructor( fun build(): EventVolumeListParams = EventVolumeListParams( + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, cursor, limit, timeframeEnd, - timeframeStart, additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), ) 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 646448c12..06e5ae206 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 @@ -6,21 +6,20 @@ import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.toUnmodifiable import com.withorb.api.models.* import java.util.Objects -import java.util.Optional class InvoiceFetchUpcomingParams constructor( - private val subscriptionId: String?, + private val subscriptionId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { - fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) + fun subscriptionId(): String = subscriptionId @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() - this.subscriptionId?.let { params.put("subscription_id", listOf(it.toString())) } + this.subscriptionId.let { params.put("subscription_id", listOf(it.toString())) } params.putAll(additionalQueryParams) return params.toUnmodifiable() } @@ -111,7 +110,7 @@ constructor( fun build(): InvoiceFetchUpcomingParams = InvoiceFetchUpcomingParams( - subscriptionId, + checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/PhantomReachableTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/PhantomReachableTest.kt new file mode 100644 index 000000000..7dec06e5c --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/PhantomReachableTest.kt @@ -0,0 +1,27 @@ +package com.withorb.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PhantomReachableTest { + + @Test + fun closeWhenPhantomReachable_whenObservedIsGarbageCollected_closesCloseable() { + var closed = false + val closeable = AutoCloseable { closed = true } + + closeWhenPhantomReachable( + // Pass an inline object for the object to observe so that it becomes immediately + // unreachable. + Any(), + closeable + ) + + assertThat(closed).isFalse() + + System.gc() + Thread.sleep(3000) + + assertThat(closed).isTrue() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventVolumeListParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventVolumeListParamsTest.kt index 52f821035..3b108799a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventVolumeListParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventVolumeListParamsTest.kt @@ -12,10 +12,10 @@ class EventVolumeListParamsTest { @Test fun createEventVolumeListParams() { EventVolumeListParams.builder() + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .cursor("cursor") .limit(123L) .timeframeEnd(OffsetDateTime.parse("2024-10-11T06:00:00Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() } @@ -23,23 +23,27 @@ class EventVolumeListParamsTest { fun getQueryParams() { val params = EventVolumeListParams.builder() + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .cursor("cursor") .limit(123L) .timeframeEnd(OffsetDateTime.parse("2024-10-11T06:00:00Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() val expected = mutableMapOf>() + expected.put("timeframe_start", listOf("2019-12-27T18:11:19.117Z")) expected.put("cursor", listOf("cursor")) expected.put("limit", listOf("123")) expected.put("timeframe_end", listOf("2024-10-11T06:00:00Z")) - expected.put("timeframe_start", listOf("2019-12-27T18:11:19.117Z")) assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = EventVolumeListParams.builder().build() + val params = + EventVolumeListParams.builder() + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() val expected = mutableMapOf>() + expected.put("timeframe_start", listOf("2019-12-27T18:11:19.117Z")) assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParamsTest.kt index 8ee3c162c..141451413 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParamsTest.kt @@ -23,8 +23,9 @@ class InvoiceFetchUpcomingParamsTest { @Test fun getQueryParamsWithoutOptionalFields() { - val params = InvoiceFetchUpcomingParams.builder().build() + val params = InvoiceFetchUpcomingParams.builder().subscriptionId("subscription_id").build() val expected = mutableMapOf>() + expected.put("subscription_id", listOf("subscription_id")) assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/VolumeServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/VolumeServiceTest.kt index 8e12f3ad8..4efc8f0b2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/VolumeServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/VolumeServiceTest.kt @@ -23,10 +23,10 @@ class VolumeServiceTest { val eventVolumes = volumeService.list( EventVolumeListParams.builder() + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .cursor("cursor") .limit(123L) .timeframeEnd(OffsetDateTime.parse("2024-10-11T06:00:00Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) println(eventVolumes) From b06d37a55e7746a5058750036acf5e7ff888f866 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 23:24:51 +0000 Subject: [PATCH 3/6] feat(api): api update (#92) --- .stats.yml | 2 +- .../main/kotlin/com/withorb/api/core/Utils.kt | 23 ++----------------- .../api/core/http/RetryingHttpClient.kt | 7 +++--- .../async/SubscriptionServiceAsync.kt | 10 ++++---- .../async/SubscriptionServiceAsyncImpl.kt | 10 ++++---- .../services/blocking/SubscriptionService.kt | 10 ++++---- .../blocking/SubscriptionServiceImpl.kt | 10 ++++---- 7 files changed, 31 insertions(+), 41 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2058bd1c6..14eb001b8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 95 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-1a0cb9f84cf6b6342b82c87ecdcba968405aac1dfb0c78eaf055a44fe15cab2c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-97c8d75c5095cb134ab45f92a057797013d174324268fcf1ba750c5ebcd9b3e4.yml diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt index 03aafb454..cf1dea288 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt @@ -9,13 +9,8 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @JvmSynthetic -internal fun T?.getOrThrow(name: String): T { - if (this == null) { - throw OrbInvalidDataException("'${name}' is not present") - } - - return this -} +internal fun T?.getOrThrow(name: String): T = + this ?: throw OrbInvalidDataException("`${name}` is not present") @JvmSynthetic internal fun List.toUnmodifiable(): List { @@ -44,18 +39,4 @@ internal fun ListMultimap.toUnmodifiable(): ListMultimap { return Multimaps.unmodifiableListMultimap(this) } -@JvmSynthetic -internal fun ListMultimap.getRequiredHeader(header: String): String { - val value = - entries() - .stream() - .filter { entry -> entry.key.equals(header, ignoreCase = true) } - .map { entry -> entry.value } - .findFirst() - if (!value.isPresent) { - throw OrbInvalidDataException("Could not find $header header") - } - return value.get() -} - internal interface Enum diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt index d5fb2fea7..896c37042 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -1,6 +1,5 @@ package com.withorb.api.core.http -import com.google.common.util.concurrent.MoreExecutors import com.withorb.api.core.RequestOptions import com.withorb.api.errors.OrbIoException import java.io.IOException @@ -116,8 +115,10 @@ private constructor( executeWithRetries(request, requestOptions) } }, - MoreExecutors.directExecutor() - ) + ) { + // Run in the same thread. + it.run() + } .thenCompose(Function.identity()) } 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 5c66c3b8b..a81993ec0 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 @@ -63,8 +63,9 @@ interface SubscriptionServiceAsync { * being created. This is useful when a customer has prices that differ from the default prices * for a specific plan. * - * :::info This feature is only available for accounts that have migrated off of legacy - * subscription overrides. ::: + * :::info 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 * @@ -689,8 +690,9 @@ interface SubscriptionServiceAsync { * you schedule the plan change. This is useful when a customer has prices that differ from the * default prices for a specific plan. * - * :::info This feature is only available for accounts that have migrated off of legacy - * subscription overrides. ::: + * :::info 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 * 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 39ea5f03a..84a27c746 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 @@ -78,8 +78,9 @@ constructor( * being created. This is useful when a customer has prices that differ from the default prices * for a specific plan. * - * :::info This feature is only available for accounts that have migrated off of legacy - * subscription overrides. ::: + * :::info 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 * @@ -911,8 +912,9 @@ constructor( * you schedule the plan change. This is useful when a customer has prices that differ from the * default prices for a specific plan. * - * :::info This feature is only available for accounts that have migrated off of legacy - * subscription overrides. ::: + * :::info 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 * 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 397ed9bcd..a1ce4f4ef 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 @@ -62,8 +62,9 @@ interface SubscriptionService { * being created. This is useful when a customer has prices that differ from the default prices * for a specific plan. * - * :::info This feature is only available for accounts that have migrated off of legacy - * subscription overrides. ::: + * :::info 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 * @@ -688,8 +689,9 @@ interface SubscriptionService { * you schedule the plan change. This is useful when a customer has prices that differ from the * default prices for a specific plan. * - * :::info This feature is only available for accounts that have migrated off of legacy - * subscription overrides. ::: + * :::info 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 * 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 6a2f48317..c4b7b3614 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 @@ -77,8 +77,9 @@ constructor( * being created. This is useful when a customer has prices that differ from the default prices * for a specific plan. * - * :::info This feature is only available for accounts that have migrated off of legacy - * subscription overrides. ::: + * :::info 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 * @@ -901,8 +902,9 @@ constructor( * you schedule the plan change. This is useful when a customer has prices that differ from the * default prices for a specific plan. * - * :::info This feature is only available for accounts that have migrated off of legacy - * subscription overrides. ::: + * :::info 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 * From 311c123cd870144fcbda844e1d9dbc0843fc320e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 19:02:27 +0000 Subject: [PATCH 4/6] feat(api): api update (#93) --- .stats.yml | 2 +- .../withorb/api/models/PlanCreateParams.kt | 1196 ++- .../kotlin/com/withorb/api/models/Price.kt | 8158 ++++++++++------- .../withorb/api/models/PriceCreateParams.kt | 977 +- .../SubscriptionPriceIntervalsParams.kt | 1233 ++- 5 files changed, 8374 insertions(+), 3192 deletions(-) diff --git a/.stats.yml b/.stats.yml index 14eb001b8..08ad8bf9a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 95 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-97c8d75c5095cb134ab45f92a057797013d174324268fcf1ba750c5ebcd9b3e4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-98c74703b2dc6ba6057447cdf65179965d7a6cee5e26cb0f019b08f5840fbc0a.yml 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 f8fea5ecc..bf5e8e828 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 @@ -458,6 +458,7 @@ constructor( null, private val newPlanGroupedWithMeteredMinimumPrice: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val newPlanMatrixWithDisplayNamePrice: NewPlanMatrixWithDisplayNamePrice? = null, private val newPlanBulkWithProrationPrice: NewPlanBulkWithProrationPrice? = null, private val _json: JsonValue? = null, ) { @@ -517,6 +518,9 @@ constructor( Optional = Optional.ofNullable(newPlanGroupedWithMeteredMinimumPrice) + fun newPlanMatrixWithDisplayNamePrice(): Optional = + Optional.ofNullable(newPlanMatrixWithDisplayNamePrice) + fun newPlanBulkWithProrationPrice(): Optional = Optional.ofNullable(newPlanBulkWithProrationPrice) @@ -559,6 +563,9 @@ constructor( fun isNewPlanGroupedWithMeteredMinimumPrice(): Boolean = newPlanGroupedWithMeteredMinimumPrice != null + fun isNewPlanMatrixWithDisplayNamePrice(): Boolean = + newPlanMatrixWithDisplayNamePrice != null + fun isNewPlanBulkWithProrationPrice(): Boolean = newPlanBulkWithProrationPrice != null fun asNewPlanUnitPrice(): NewPlanUnitPrice = newPlanUnitPrice.getOrThrow("newPlanUnitPrice") @@ -616,6 +623,9 @@ constructor( "newPlanGroupedWithMeteredMinimumPrice" ) + fun asNewPlanMatrixWithDisplayNamePrice(): NewPlanMatrixWithDisplayNamePrice = + newPlanMatrixWithDisplayNamePrice.getOrThrow("newPlanMatrixWithDisplayNamePrice") + fun asNewPlanBulkWithProrationPrice(): NewPlanBulkWithProrationPrice = newPlanBulkWithProrationPrice.getOrThrow("newPlanBulkWithProrationPrice") @@ -658,6 +668,10 @@ constructor( visitor.visitNewPlanGroupedWithMeteredMinimumPrice( newPlanGroupedWithMeteredMinimumPrice ) + newPlanMatrixWithDisplayNamePrice != null -> + visitor.visitNewPlanMatrixWithDisplayNamePrice( + newPlanMatrixWithDisplayNamePrice + ) newPlanBulkWithProrationPrice != null -> visitor.visitNewPlanBulkWithProrationPrice(newPlanBulkWithProrationPrice) else -> visitor.unknown(_json) @@ -685,6 +699,7 @@ constructor( newPlanGroupedAllocationPrice == null && newPlanGroupedWithProratedMinimumPrice == null && newPlanGroupedWithMeteredMinimumPrice == null && + newPlanMatrixWithDisplayNamePrice == null && newPlanBulkWithProrationPrice == null ) { throw OrbInvalidDataException("Unknown Price: $_json") @@ -707,6 +722,7 @@ constructor( newPlanGroupedAllocationPrice?.validate() newPlanGroupedWithProratedMinimumPrice?.validate() newPlanGroupedWithMeteredMinimumPrice?.validate() + newPlanMatrixWithDisplayNamePrice?.validate() newPlanBulkWithProrationPrice?.validate() validated = true } @@ -717,11 +733,11 @@ constructor( return true } - return /* spotless:off */ other is Price && this.newPlanUnitPrice == other.newPlanUnitPrice && this.newPlanPackagePrice == other.newPlanPackagePrice && this.newPlanMatrixPrice == other.newPlanMatrixPrice && this.newPlanTieredPrice == other.newPlanTieredPrice && this.newPlanTieredBpsPrice == other.newPlanTieredBpsPrice && this.newPlanBpsPrice == other.newPlanBpsPrice && this.newPlanBulkBpsPrice == other.newPlanBulkBpsPrice && this.newPlanBulkPrice == other.newPlanBulkPrice && this.newPlanThresholdTotalAmountPrice == other.newPlanThresholdTotalAmountPrice && this.newPlanTieredPackagePrice == other.newPlanTieredPackagePrice && this.newPlanTieredWithMinimumPrice == other.newPlanTieredWithMinimumPrice && this.newPlanUnitWithPercentPrice == other.newPlanUnitWithPercentPrice && this.newPlanPackageWithAllocationPrice == other.newPlanPackageWithAllocationPrice && this.newPlanTierWithProrationPrice == other.newPlanTierWithProrationPrice && this.newPlanUnitWithProrationPrice == other.newPlanUnitWithProrationPrice && this.newPlanGroupedAllocationPrice == other.newPlanGroupedAllocationPrice && this.newPlanGroupedWithProratedMinimumPrice == other.newPlanGroupedWithProratedMinimumPrice && this.newPlanGroupedWithMeteredMinimumPrice == other.newPlanGroupedWithMeteredMinimumPrice && this.newPlanBulkWithProrationPrice == other.newPlanBulkWithProrationPrice /* spotless:on */ + return /* spotless:off */ other is Price && this.newPlanUnitPrice == other.newPlanUnitPrice && this.newPlanPackagePrice == other.newPlanPackagePrice && this.newPlanMatrixPrice == other.newPlanMatrixPrice && this.newPlanTieredPrice == other.newPlanTieredPrice && this.newPlanTieredBpsPrice == other.newPlanTieredBpsPrice && this.newPlanBpsPrice == other.newPlanBpsPrice && this.newPlanBulkBpsPrice == other.newPlanBulkBpsPrice && this.newPlanBulkPrice == other.newPlanBulkPrice && this.newPlanThresholdTotalAmountPrice == other.newPlanThresholdTotalAmountPrice && this.newPlanTieredPackagePrice == other.newPlanTieredPackagePrice && this.newPlanTieredWithMinimumPrice == other.newPlanTieredWithMinimumPrice && this.newPlanUnitWithPercentPrice == other.newPlanUnitWithPercentPrice && this.newPlanPackageWithAllocationPrice == other.newPlanPackageWithAllocationPrice && this.newPlanTierWithProrationPrice == other.newPlanTierWithProrationPrice && this.newPlanUnitWithProrationPrice == other.newPlanUnitWithProrationPrice && this.newPlanGroupedAllocationPrice == other.newPlanGroupedAllocationPrice && this.newPlanGroupedWithProratedMinimumPrice == other.newPlanGroupedWithProratedMinimumPrice && this.newPlanGroupedWithMeteredMinimumPrice == other.newPlanGroupedWithMeteredMinimumPrice && this.newPlanMatrixWithDisplayNamePrice == other.newPlanMatrixWithDisplayNamePrice && this.newPlanBulkWithProrationPrice == other.newPlanBulkWithProrationPrice /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(newPlanUnitPrice, newPlanPackagePrice, newPlanMatrixPrice, newPlanTieredPrice, newPlanTieredBpsPrice, newPlanBpsPrice, newPlanBulkBpsPrice, newPlanBulkPrice, newPlanThresholdTotalAmountPrice, newPlanTieredPackagePrice, newPlanTieredWithMinimumPrice, newPlanUnitWithPercentPrice, newPlanPackageWithAllocationPrice, newPlanTierWithProrationPrice, newPlanUnitWithProrationPrice, newPlanGroupedAllocationPrice, newPlanGroupedWithProratedMinimumPrice, newPlanGroupedWithMeteredMinimumPrice, newPlanBulkWithProrationPrice) /* spotless:on */ + return /* spotless:off */ Objects.hash(newPlanUnitPrice, newPlanPackagePrice, newPlanMatrixPrice, newPlanTieredPrice, newPlanTieredBpsPrice, newPlanBpsPrice, newPlanBulkBpsPrice, newPlanBulkPrice, newPlanThresholdTotalAmountPrice, newPlanTieredPackagePrice, newPlanTieredWithMinimumPrice, newPlanUnitWithPercentPrice, newPlanPackageWithAllocationPrice, newPlanTierWithProrationPrice, newPlanUnitWithProrationPrice, newPlanGroupedAllocationPrice, newPlanGroupedWithProratedMinimumPrice, newPlanGroupedWithMeteredMinimumPrice, newPlanMatrixWithDisplayNamePrice, newPlanBulkWithProrationPrice) /* spotless:on */ } override fun toString(): String { @@ -755,6 +771,8 @@ constructor( "Price{newPlanGroupedWithProratedMinimumPrice=$newPlanGroupedWithProratedMinimumPrice}" newPlanGroupedWithMeteredMinimumPrice != null -> "Price{newPlanGroupedWithMeteredMinimumPrice=$newPlanGroupedWithMeteredMinimumPrice}" + newPlanMatrixWithDisplayNamePrice != null -> + "Price{newPlanMatrixWithDisplayNamePrice=$newPlanMatrixWithDisplayNamePrice}" newPlanBulkWithProrationPrice != null -> "Price{newPlanBulkWithProrationPrice=$newPlanBulkWithProrationPrice}" _json != null -> "Price{_unknown=$_json}" @@ -848,6 +866,11 @@ constructor( newPlanGroupedWithMeteredMinimumPrice: NewPlanGroupedWithMeteredMinimumPrice ) = Price(newPlanGroupedWithMeteredMinimumPrice = newPlanGroupedWithMeteredMinimumPrice) + @JvmStatic + fun ofNewPlanMatrixWithDisplayNamePrice( + newPlanMatrixWithDisplayNamePrice: NewPlanMatrixWithDisplayNamePrice + ) = Price(newPlanMatrixWithDisplayNamePrice = newPlanMatrixWithDisplayNamePrice) + @JvmStatic fun ofNewPlanBulkWithProrationPrice( newPlanBulkWithProrationPrice: NewPlanBulkWithProrationPrice @@ -912,6 +935,10 @@ constructor( newPlanGroupedWithMeteredMinimumPrice: NewPlanGroupedWithMeteredMinimumPrice ): T + fun visitNewPlanMatrixWithDisplayNamePrice( + newPlanMatrixWithDisplayNamePrice: NewPlanMatrixWithDisplayNamePrice + ): T + fun visitNewPlanBulkWithProrationPrice( newPlanBulkWithProrationPrice: NewPlanBulkWithProrationPrice ): T @@ -1075,6 +1102,14 @@ constructor( ) } } + "matrix_with_display_name" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanMatrixWithDisplayNamePrice = it, _json = json) + } + } "bulk_with_proration" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() @@ -1130,6 +1165,8 @@ constructor( generator.writeObject(value.newPlanGroupedWithProratedMinimumPrice) value.newPlanGroupedWithMeteredMinimumPrice != null -> generator.writeObject(value.newPlanGroupedWithMeteredMinimumPrice) + value.newPlanMatrixWithDisplayNamePrice != null -> + generator.writeObject(value.newPlanMatrixWithDisplayNamePrice) value.newPlanBulkWithProrationPrice != null -> generator.writeObject(value.newPlanBulkWithProrationPrice) value._json != null -> generator.writeObject(value._json) @@ -22853,6 +22890,1161 @@ constructor( "NewPlanGroupedWithMeteredMinimumPrice{metadata=$metadata, externalPriceId=$externalPriceId, name=$name, billableMetricId=$billableMetricId, itemId=$itemId, billedInAdvance=$billedInAdvance, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, conversionRate=$conversionRate, modelType=$modelType, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, currency=$currency, additionalProperties=$additionalProperties}" } + @JsonDeserialize(builder = NewPlanMatrixWithDisplayNamePrice.Builder::class) + @NoAutoDetect + class NewPlanMatrixWithDisplayNamePrice + private constructor( + private val metadata: JsonField, + private val externalPriceId: JsonField, + private val name: JsonField, + private val billableMetricId: JsonField, + private val itemId: JsonField, + private val billedInAdvance: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val cadence: JsonField, + private val billingCycleConfiguration: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val modelType: JsonField, + private val matrixWithDisplayNameConfig: JsonField, + private val currency: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** 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")) + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * If the Price 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, 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")) + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId() = externalPriceId + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name() = 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() = billableMetricId + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + /** + * If 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() = billedInAdvance + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity() = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey() = invoiceGroupingKey + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration() = billingCycleConfiguration + + /** + * 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() = invoicingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + + @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig() = matrixWithDisplayNameConfig + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): NewPlanMatrixWithDisplayNamePrice = apply { + if (!validated) { + metadata().map { it.validate() } + externalPriceId() + name() + billableMetricId() + itemId() + billedInAdvance() + fixedPriceQuantity() + invoiceGroupingKey() + cadence() + billingCycleConfiguration().map { it.validate() } + invoicingCycleConfiguration().map { it.validate() } + conversionRate() + modelType() + matrixWithDisplayNameConfig().validate() + currency() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var billableMetricId: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var cadence: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var modelType: JsonField = JsonMissing.of() + private var matrixWithDisplayNameConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newPlanMatrixWithDisplayNamePrice: NewPlanMatrixWithDisplayNamePrice + ) = apply { + this.metadata = newPlanMatrixWithDisplayNamePrice.metadata + this.externalPriceId = newPlanMatrixWithDisplayNamePrice.externalPriceId + this.name = newPlanMatrixWithDisplayNamePrice.name + this.billableMetricId = newPlanMatrixWithDisplayNamePrice.billableMetricId + this.itemId = newPlanMatrixWithDisplayNamePrice.itemId + this.billedInAdvance = newPlanMatrixWithDisplayNamePrice.billedInAdvance + this.fixedPriceQuantity = newPlanMatrixWithDisplayNamePrice.fixedPriceQuantity + this.invoiceGroupingKey = newPlanMatrixWithDisplayNamePrice.invoiceGroupingKey + this.cadence = newPlanMatrixWithDisplayNamePrice.cadence + this.billingCycleConfiguration = + newPlanMatrixWithDisplayNamePrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + newPlanMatrixWithDisplayNamePrice.invoicingCycleConfiguration + this.conversionRate = newPlanMatrixWithDisplayNamePrice.conversionRate + this.modelType = newPlanMatrixWithDisplayNamePrice.modelType + this.matrixWithDisplayNameConfig = + newPlanMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig + this.currency = newPlanMatrixWithDisplayNamePrice.currency + additionalProperties(newPlanMatrixWithDisplayNamePrice.additionalProperties) + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by 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. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String) = + externalPriceId(JsonField.of(externalPriceId)) + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + @JsonProperty("name") + @ExcludeMissing + 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.of(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(JsonField.of(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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String) = + invoiceGroupingKey(JsonField.of(invoiceGroupingKey)) + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfiguration + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: InvoicingCycleConfiguration + ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + + /** + * 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( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(JsonField.of(conversionRate)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + @JsonProperty("model_type") + @ExcludeMissing + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): NewPlanMatrixWithDisplayNamePrice = + NewPlanMatrixWithDisplayNamePrice( + metadata, + externalPriceId, + name, + billableMetricId, + itemId, + billedInAdvance, + fixedPriceQuantity, + invoiceGroupingKey, + cadence, + billingCycleConfiguration, + invoicingCycleConfiguration, + conversionRate, + modelType, + matrixWithDisplayNameConfig, + currency, + additionalProperties.toUnmodifiable(), + ) + } + + class Cadence + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ANNUAL = Cadence(JsonField.of("annual")) + + @JvmField val SEMI_ANNUAL = Cadence(JsonField.of("semi_annual")) + + @JvmField val MONTHLY = Cadence(JsonField.of("monthly")) + + @JvmField val QUARTERLY = Cadence(JsonField.of("quarterly")) + + @JvmField val ONE_TIME = Cadence(JsonField.of("one_time")) + + @JvmField val CUSTOM = Cadence(JsonField.of("custom")) + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ANNUAL -> 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 known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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 asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = MatrixWithDisplayNameConfig.Builder::class) + @NoAutoDetect + class MatrixWithDisplayNameConfig + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = + apply { + additionalProperties(matrixWithDisplayNameConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixWithDisplayNameConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + } + + class ModelType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val MATRIX_WITH_DISPLAY_NAME = + ModelType(JsonField.of("matrix_with_display_name")) + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + enum class Known { + MATRIX_WITH_DISPLAY_NAME, + } + + enum class Value { + MATRIX_WITH_DISPLAY_NAME, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonDeserialize(builder = BillingCycleConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleConfiguration + private constructor( + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The duration of the billing period. */ + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var duration: JsonField = JsonMissing.of() + private var durationUnit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = + apply { + this.duration = billingCycleConfiguration.duration + this.durationUnit = billingCycleConfiguration.durationUnit + additionalProperties(billingCycleConfiguration.additionalProperties) + } + + /** The duration of the billing period. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleConfiguration = + BillingCycleConfiguration( + duration, + durationUnit, + additionalProperties.toUnmodifiable(), + ) + } + + class DurationUnit + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = DurationUnit(JsonField.of("day")) + + @JvmField val MONTH = DurationUnit(JsonField.of("month")) + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleConfiguration && this.duration == other.duration && this.durationUnit == other.durationUnit && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(duration, durationUnit, additionalProperties) /* spotless:on */ + } + return 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. + */ + @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) + @NoAutoDetect + class InvoicingCycleConfiguration + private constructor( + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The duration of the billing period. */ + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var duration: JsonField = JsonMissing.of() + private var durationUnit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = + apply { + this.duration = invoicingCycleConfiguration.duration + this.durationUnit = invoicingCycleConfiguration.durationUnit + additionalProperties(invoicingCycleConfiguration.additionalProperties) + } + + /** The duration of the billing period. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InvoicingCycleConfiguration = + InvoicingCycleConfiguration( + duration, + durationUnit, + additionalProperties.toUnmodifiable(), + ) + } + + class DurationUnit + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = DurationUnit(JsonField.of("day")) + + @JvmField val MONTH = DurationUnit(JsonField.of("month")) + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoicingCycleConfiguration && this.duration == other.duration && this.durationUnit == other.durationUnit && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(duration, durationUnit, additionalProperties) /* spotless:on */ + } + return 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewPlanMatrixWithDisplayNamePrice && this.metadata == other.metadata && this.externalPriceId == other.externalPriceId && this.name == other.name && this.billableMetricId == other.billableMetricId && this.itemId == other.itemId && this.billedInAdvance == other.billedInAdvance && this.fixedPriceQuantity == other.fixedPriceQuantity && this.invoiceGroupingKey == other.invoiceGroupingKey && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.conversionRate == other.conversionRate && this.modelType == other.modelType && this.matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && this.currency == other.currency && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, externalPriceId, name, billableMetricId, itemId, billedInAdvance, fixedPriceQuantity, invoiceGroupingKey, cadence, billingCycleConfiguration, invoicingCycleConfiguration, conversionRate, modelType, matrixWithDisplayNameConfig, currency, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "NewPlanMatrixWithDisplayNamePrice{metadata=$metadata, externalPriceId=$externalPriceId, name=$name, billableMetricId=$billableMetricId, itemId=$itemId, billedInAdvance=$billedInAdvance, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, conversionRate=$conversionRate, modelType=$modelType, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, currency=$currency, additionalProperties=$additionalProperties}" + } + @JsonDeserialize(builder = NewPlanBulkWithProrationPrice.Builder::class) @NoAutoDetect class NewPlanBulkWithProrationPrice 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 3ba78fe9e..296cbb786 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 @@ -54,6 +54,7 @@ private constructor( 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 _json: JsonValue? = null, ) { @@ -113,6 +114,9 @@ private constructor( fun groupedWithMeteredMinimumPrice(): Optional = Optional.ofNullable(groupedWithMeteredMinimumPrice) + fun matrixWithDisplayNamePrice(): Optional = + Optional.ofNullable(matrixWithDisplayNamePrice) + fun bulkWithProrationPrice(): Optional = Optional.ofNullable(bulkWithProrationPrice) @@ -158,6 +162,8 @@ private constructor( fun isGroupedWithMeteredMinimumPrice(): Boolean = groupedWithMeteredMinimumPrice != null + fun isMatrixWithDisplayNamePrice(): Boolean = matrixWithDisplayNamePrice != null + fun isBulkWithProrationPrice(): Boolean = bulkWithProrationPrice != null fun asUnitPrice(): UnitPrice = unitPrice.getOrThrow("unitPrice") @@ -215,6 +221,9 @@ private constructor( fun asGroupedWithMeteredMinimumPrice(): GroupedWithMeteredMinimumPrice = groupedWithMeteredMinimumPrice.getOrThrow("groupedWithMeteredMinimumPrice") + fun asMatrixWithDisplayNamePrice(): MatrixWithDisplayNamePrice = + matrixWithDisplayNamePrice.getOrThrow("matrixWithDisplayNamePrice") + fun asBulkWithProrationPrice(): BulkWithProrationPrice = bulkWithProrationPrice.getOrThrow("bulkWithProrationPrice") @@ -253,6 +262,8 @@ private constructor( visitor.visitGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice) groupedWithMeteredMinimumPrice != null -> visitor.visitGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice) + matrixWithDisplayNamePrice != null -> + visitor.visitMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice) bulkWithProrationPrice != null -> visitor.visitBulkWithProrationPrice(bulkWithProrationPrice) else -> visitor.unknown(_json) @@ -283,6 +294,7 @@ private constructor( groupedAllocationPrice == null && groupedWithProratedMinimumPrice == null && groupedWithMeteredMinimumPrice == null && + matrixWithDisplayNamePrice == null && bulkWithProrationPrice == null ) { throw OrbInvalidDataException("Unknown Price: $_json") @@ -308,6 +320,7 @@ private constructor( groupedAllocationPrice?.validate() groupedWithProratedMinimumPrice?.validate() groupedWithMeteredMinimumPrice?.validate() + matrixWithDisplayNamePrice?.validate() bulkWithProrationPrice?.validate() validated = true } @@ -318,11 +331,11 @@ private constructor( return true } - return /* spotless:off */ other is Price && this.unitPrice == other.unitPrice && this.packagePrice == other.packagePrice && this.matrixPrice == other.matrixPrice && this.tieredPrice == other.tieredPrice && this.tieredBpsPrice == other.tieredBpsPrice && this.bpsPrice == other.bpsPrice && this.bulkBpsPrice == other.bulkBpsPrice && this.bulkPrice == other.bulkPrice && this.thresholdTotalAmountPrice == other.thresholdTotalAmountPrice && this.tieredPackagePrice == other.tieredPackagePrice && this.groupedTieredPrice == other.groupedTieredPrice && this.tieredWithMinimumPrice == other.tieredWithMinimumPrice && this.tieredPackageWithMinimumPrice == other.tieredPackageWithMinimumPrice && this.packageWithAllocationPrice == other.packageWithAllocationPrice && this.unitWithPercentPrice == other.unitWithPercentPrice && this.matrixWithAllocationPrice == other.matrixWithAllocationPrice && this.tieredWithProrationPrice == other.tieredWithProrationPrice && this.unitWithProrationPrice == other.unitWithProrationPrice && this.groupedAllocationPrice == other.groupedAllocationPrice && this.groupedWithProratedMinimumPrice == other.groupedWithProratedMinimumPrice && this.groupedWithMeteredMinimumPrice == other.groupedWithMeteredMinimumPrice && this.bulkWithProrationPrice == other.bulkWithProrationPrice /* spotless:on */ + return /* spotless:off */ other is Price && this.unitPrice == other.unitPrice && this.packagePrice == other.packagePrice && this.matrixPrice == other.matrixPrice && this.tieredPrice == other.tieredPrice && this.tieredBpsPrice == other.tieredBpsPrice && this.bpsPrice == other.bpsPrice && this.bulkBpsPrice == other.bulkBpsPrice && this.bulkPrice == other.bulkPrice && this.thresholdTotalAmountPrice == other.thresholdTotalAmountPrice && this.tieredPackagePrice == other.tieredPackagePrice && this.groupedTieredPrice == other.groupedTieredPrice && this.tieredWithMinimumPrice == other.tieredWithMinimumPrice && this.tieredPackageWithMinimumPrice == other.tieredPackageWithMinimumPrice && this.packageWithAllocationPrice == other.packageWithAllocationPrice && this.unitWithPercentPrice == other.unitWithPercentPrice && this.matrixWithAllocationPrice == other.matrixWithAllocationPrice && this.tieredWithProrationPrice == other.tieredWithProrationPrice && this.unitWithProrationPrice == other.unitWithProrationPrice && this.groupedAllocationPrice == other.groupedAllocationPrice && this.groupedWithProratedMinimumPrice == other.groupedWithProratedMinimumPrice && this.groupedWithMeteredMinimumPrice == other.groupedWithMeteredMinimumPrice && this.matrixWithDisplayNamePrice == other.matrixWithDisplayNamePrice && this.bulkWithProrationPrice == other.bulkWithProrationPrice /* spotless:on */ } override fun hashCode(): Int { - return /* 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, bulkWithProrationPrice) /* spotless:on */ + return /* 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) /* spotless:on */ } override fun toString(): String { @@ -358,6 +371,8 @@ private constructor( "Price{groupedWithProratedMinimumPrice=$groupedWithProratedMinimumPrice}" groupedWithMeteredMinimumPrice != null -> "Price{groupedWithMeteredMinimumPrice=$groupedWithMeteredMinimumPrice}" + matrixWithDisplayNamePrice != null -> + "Price{matrixWithDisplayNamePrice=$matrixWithDisplayNamePrice}" bulkWithProrationPrice != null -> "Price{bulkWithProrationPrice=$bulkWithProrationPrice}" _json != null -> "Price{_unknown=$_json}" @@ -442,6 +457,10 @@ private constructor( groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice ) = Price(groupedWithMeteredMinimumPrice = groupedWithMeteredMinimumPrice) + @JvmStatic + fun ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice) = + Price(matrixWithDisplayNamePrice = matrixWithDisplayNamePrice) + @JvmStatic fun ofBulkWithProrationPrice(bulkWithProrationPrice: BulkWithProrationPrice) = Price(bulkWithProrationPrice = bulkWithProrationPrice) @@ -499,6 +518,10 @@ private constructor( groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice ): T + fun visitMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice + ): T + fun visitBulkWithProrationPrice(bulkWithProrationPrice: BulkWithProrationPrice): T fun unknown(json: JsonValue?): T { @@ -653,6 +676,14 @@ private constructor( return Price(groupedWithMeteredMinimumPrice = it, _json = json) } } + "matrix_with_display_name" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(matrixWithDisplayNamePrice = it, _json = json) + } + } "bulk_with_proration" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -705,6 +736,8 @@ private constructor( 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._json != null -> generator.writeObject(value._json) @@ -2281,115 +2314,1843 @@ private constructor( companion object { - @JvmField val UNIT = ModelType(JsonField.of("unit")) + @JvmField val UNIT = ModelType(JsonField.of("unit")) + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + enum class Known { + UNIT, + } + + enum class Value { + UNIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + UNIT -> Value.UNIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + UNIT -> Known.UNIT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class PriceType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE_PRICE = PriceType(JsonField.of("usage_price")) + + @JvmField val FIXED_PRICE = PriceType(JsonField.of("fixed_price")) + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = UnitConfig.Builder::class) + @NoAutoDetect + class UnitConfig + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** Rate per unit of usage */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var unitAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitConfig: UnitConfig) = apply { + this.unitAmount = unitConfig.unitAmount + additionalProperties(unitConfig.additionalProperties) + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UnitConfig = + UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnitConfig && this.unitAmount == other.unitAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(unitAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnitPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.unitConfig == other.unitConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, unitConfig, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UnitPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, unitConfig=$unitConfig, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PackagePrice.Builder::class) + @NoAutoDetect + class PackagePrice + private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val name: JsonField, + private val externalPriceId: JsonField, + private val priceType: JsonField, + private val modelType: JsonField, + private val createdAt: JsonField, + private val cadence: JsonField, + private val billingCycleConfiguration: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val billableMetric: JsonField, + private val fixedPriceQuantity: JsonField, + private val planPhaseOrder: JsonField, + private val currency: JsonField, + private val conversionRate: JsonField, + private val item: JsonField, + private val creditAllocation: JsonField, + private val discount: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val packageConfig: JsonField, + private val additionalProperties: Map, + ) { + + 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 id(): String = id.getRequired("id") + + fun name(): String = name.getRequired("name") + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun currency(): String = currency.getRequired("currency") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun item(): Item = item.getRequired("item") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + + @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + + @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration() = billingCycleConfiguration + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + + @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity() = fixedPriceQuantity + + @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + + @JsonProperty("item") @ExcludeMissing fun _item() = item + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation() = creditAllocation + + @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + + @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonProperty("package_config") @ExcludeMissing fun _packageConfig() = packageConfig + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PackagePrice = apply { + if (!validated) { + metadata().validate() + id() + name() + externalPriceId() + priceType() + modelType() + createdAt() + cadence() + billingCycleConfiguration().validate() + invoicingCycleConfiguration().map { it.validate() } + billableMetric().map { it.validate() } + fixedPriceQuantity() + planPhaseOrder() + currency() + conversionRate() + item().validate() + creditAllocation().map { it.validate() } + discount() + minimum().map { it.validate() } + minimumAmount() + maximum().map { it.validate() } + maximumAmount() + packageConfig().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var priceType: JsonField = JsonMissing.of() + private var modelType: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var cadence: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var billableMetric: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var item: JsonField = JsonMissing.of() + private var creditAllocation: JsonField = JsonMissing.of() + private var discount: JsonField = JsonMissing.of() + private var minimum: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var maximum: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var packageConfig: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packagePrice: PackagePrice) = apply { + this.metadata = packagePrice.metadata + this.id = packagePrice.id + this.name = packagePrice.name + this.externalPriceId = packagePrice.externalPriceId + this.priceType = packagePrice.priceType + this.modelType = packagePrice.modelType + this.createdAt = packagePrice.createdAt + this.cadence = packagePrice.cadence + this.billingCycleConfiguration = packagePrice.billingCycleConfiguration + this.invoicingCycleConfiguration = packagePrice.invoicingCycleConfiguration + this.billableMetric = packagePrice.billableMetric + this.fixedPriceQuantity = packagePrice.fixedPriceQuantity + this.planPhaseOrder = packagePrice.planPhaseOrder + this.currency = packagePrice.currency + this.conversionRate = packagePrice.conversionRate + this.item = packagePrice.item + this.creditAllocation = packagePrice.creditAllocation + this.discount = packagePrice.discount + this.minimum = packagePrice.minimum + this.minimumAmount = packagePrice.minimumAmount + this.maximum = packagePrice.maximum + this.maximumAmount = packagePrice.maximumAmount + this.packageConfig = packagePrice.packageConfig + additionalProperties(packagePrice.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun externalPriceId(externalPriceId: String) = + externalPriceId(JsonField.of(externalPriceId)) + + @JsonProperty("external_price_id") + @ExcludeMissing + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + @JsonProperty("price_type") + @ExcludeMissing + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + @JsonProperty("model_type") + @ExcludeMissing + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + @JsonProperty("cadence") + @ExcludeMissing + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: InvoicingCycleConfiguration + ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun billableMetric(billableMetric: BillableMetric) = + billableMetric(JsonField.of(billableMetric)) + + @JsonProperty("billable_metric") + @ExcludeMissing + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun conversionRate(conversionRate: Double) = + conversionRate(JsonField.of(conversionRate)) + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun item(item: Item) = item(JsonField.of(item)) + + @JsonProperty("item") + @ExcludeMissing + fun item(item: JsonField) = apply { this.item = item } + + fun creditAllocation(creditAllocation: CreditAllocation) = + creditAllocation(JsonField.of(creditAllocation)) + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun discount(discount: Discount) = discount(JsonField.of(discount)) + + @JsonProperty("discount") + @ExcludeMissing + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + + @JsonProperty("minimum") + @ExcludeMissing + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + + @JsonProperty("maximum") + @ExcludeMissing + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) + + @JsonProperty("package_config") + @ExcludeMissing + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PackagePrice = + PackagePrice( + metadata, + id, + name, + externalPriceId, + priceType, + modelType, + createdAt, + cadence, + billingCycleConfiguration, + invoicingCycleConfiguration, + billableMetric, + fixedPriceQuantity, + planPhaseOrder, + currency, + conversionRate, + item, + creditAllocation, + discount, + minimum, + minimumAmount, + maximum, + maximumAmount, + packageConfig, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = BillableMetric.Builder::class) + @NoAutoDetect + class BillableMetric + private constructor( + private val id: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillableMetric = apply { + if (!validated) { + id() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billableMetric: BillableMetric) = apply { + this.id = billableMetric.id + additionalProperties(billableMetric.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillableMetric = + BillableMetric(id, additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillableMetric && this.id == other.id && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "BillableMetric{id=$id, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleConfiguration + private constructor( + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun duration(): Long = duration.getRequired("duration") + + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + + @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var duration: JsonField = JsonMissing.of() + private var durationUnit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { + this.duration = billingCycleConfiguration.duration + this.durationUnit = billingCycleConfiguration.durationUnit + additionalProperties(billingCycleConfiguration.additionalProperties) + } + + fun duration(duration: Long) = duration(JsonField.of(duration)) + + @JsonProperty("duration") + @ExcludeMissing + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + @JsonProperty("duration_unit") + @ExcludeMissing + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleConfiguration = + BillingCycleConfiguration( + duration, + durationUnit, + additionalProperties.toUnmodifiable(), + ) + } + + class DurationUnit + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = DurationUnit(JsonField.of("day")) + + @JvmField val MONTH = DurationUnit(JsonField.of("month")) + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleConfiguration && this.duration == other.duration && this.durationUnit == other.durationUnit && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(duration, durationUnit, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + } + + class Cadence + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ONE_TIME = Cadence(JsonField.of("one_time")) + + @JvmField val MONTHLY = Cadence(JsonField.of("monthly")) + + @JvmField val QUARTERLY = Cadence(JsonField.of("quarterly")) + + @JvmField val SEMI_ANNUAL = Cadence(JsonField.of("semi_annual")) + + @JvmField val ANNUAL = Cadence(JsonField.of("annual")) + + @JvmField val CUSTOM = Cadence(JsonField.of("custom")) + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + _UNKNOWN, + } + + 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 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 asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = CreditAllocation.Builder::class) + @NoAutoDetect + class CreditAllocation + private constructor( + private val currency: JsonField, + private val allowsRollover: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun currency(): String = currency.getRequired("currency") + + fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CreditAllocation = apply { + if (!validated) { + currency() + allowsRollover() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditAllocation: CreditAllocation) = apply { + this.currency = creditAllocation.currency + this.allowsRollover = creditAllocation.allowsRollover + additionalProperties(creditAllocation.additionalProperties) + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun allowsRollover(allowsRollover: Boolean) = + allowsRollover(JsonField.of(allowsRollover)) + + @JsonProperty("allows_rollover") + @ExcludeMissing + fun allowsRollover(allowsRollover: JsonField) = apply { + this.allowsRollover = allowsRollover + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CreditAllocation = + CreditAllocation( + currency, + allowsRollover, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreditAllocation && this.currency == other.currency && this.allowsRollover == other.allowsRollover && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(currency, allowsRollover, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "CreditAllocation{currency=$currency, allowsRollover=$allowsRollover, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) + @NoAutoDetect + class InvoicingCycleConfiguration + private constructor( + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun duration(): Long = duration.getRequired("duration") + + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + + @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var duration: JsonField = JsonMissing.of() + private var durationUnit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = + apply { + this.duration = invoicingCycleConfiguration.duration + this.durationUnit = invoicingCycleConfiguration.durationUnit + additionalProperties(invoicingCycleConfiguration.additionalProperties) + } + + fun duration(duration: Long) = duration(JsonField.of(duration)) + + @JsonProperty("duration") + @ExcludeMissing + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + @JsonProperty("duration_unit") + @ExcludeMissing + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InvoicingCycleConfiguration = + InvoicingCycleConfiguration( + duration, + durationUnit, + additionalProperties.toUnmodifiable(), + ) + } + + class DurationUnit + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = DurationUnit(JsonField.of("day")) + + @JvmField val MONTH = DurationUnit(JsonField.of("month")) + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoicingCycleConfiguration && this.duration == other.duration && this.durationUnit == other.durationUnit && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(duration, durationUnit, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Item.Builder::class) + @NoAutoDetect + class Item + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun name(): String = name.getRequired("name") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Item = apply { + if (!validated) { + id() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + this.id = item.id + this.name = item.name + additionalProperties(item.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Item = + Item( + id, + name, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Item && this.id == other.id && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Maximum.Builder::class) + @NoAutoDetect + class Maximum + private constructor( + private val maximumAmount: JsonField, + private val appliesToPriceIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** 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. + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** Maximum amount applied */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + /** + * 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() = appliesToPriceIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Maximum = apply { + if (!validated) { + maximumAmount() + appliesToPriceIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximum: Maximum) = apply { + this.maximumAmount = maximum.maximumAmount + this.appliesToPriceIds = maximum.appliesToPriceIds + additionalProperties(maximum.additionalProperties) + } + + /** Maximum amount applied */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) + + /** Maximum amount applied */ + @JsonProperty("maximum_amount") + @ExcludeMissing + 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. + */ + 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. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Maximum = + Maximum( + maximumAmount, + appliesToPriceIds.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Maximum && this.maximumAmount == other.maximumAmount && this.appliesToPriceIds == other.appliesToPriceIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(maximumAmount, appliesToPriceIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Maximum{maximumAmount=$maximumAmount, appliesToPriceIds=$appliesToPriceIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Minimum.Builder::class) + @NoAutoDetect + class Minimum + private constructor( + private val minimumAmount: JsonField, + private val appliesToPriceIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** 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. + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** Minimum amount applied */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** + * 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() = appliesToPriceIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Minimum = apply { + if (!validated) { + minimumAmount() + appliesToPriceIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimum: Minimum) = apply { + this.minimumAmount = minimum.minimumAmount + this.appliesToPriceIds = minimum.appliesToPriceIds + additionalProperties(minimum.additionalProperties) + } + + /** Minimum amount applied */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** Minimum amount applied */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * 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. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Minimum = + Minimum( + minimumAmount, + appliesToPriceIds.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Minimum && this.minimumAmount == other.minimumAmount && this.appliesToPriceIds == other.appliesToPriceIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(minimumAmount, appliesToPriceIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Minimum{minimumAmount=$minimumAmount, appliesToPriceIds=$appliesToPriceIds, additionalProperties=$additionalProperties}" + } + + class ModelType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PACKAGE = ModelType(JsonField.of("package")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - UNIT, + PACKAGE, } enum class Value { - UNIT, + PACKAGE, _UNKNOWN, } fun value(): Value = when (this) { - UNIT -> Value.UNIT + PACKAGE -> Value.PACKAGE else -> Value._UNKNOWN } fun known(): Known = when (this) { - UNIT -> Known.UNIT + PACKAGE -> Known.PACKAGE else -> throw OrbInvalidDataException("Unknown ModelType: $value") } fun asString(): String = _value().asStringOrThrow() } - class PriceType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USAGE_PRICE = PriceType(JsonField.of("usage_price")) - - @JvmField val FIXED_PRICE = PriceType(JsonField.of("fixed_price")) - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = UnitConfig.Builder::class) + @JsonDeserialize(builder = PackageConfig.Builder::class) @NoAutoDetect - class UnitConfig + class PackageConfig private constructor( - private val unitAmount: JsonField, + private val packageAmount: JsonField, + private val packageSize: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** A currency amount to rate usage by */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") - /** Rate per unit of usage */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + /** + * 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() = 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() = packageSize @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnitConfig = apply { + fun validate(): PackageConfig = apply { if (!validated) { - unitAmount() + packageAmount() + packageSize() validated = true } } @@ -2403,23 +4164,42 @@ private constructor( class Builder { - private var unitAmount: JsonField = JsonMissing.of() + private var packageAmount: JsonField = JsonMissing.of() + private var packageSize: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - this.unitAmount = unitConfig.unitAmount - additionalProperties(unitConfig.additionalProperties) + internal fun from(packageConfig: PackageConfig) = apply { + this.packageAmount = packageConfig.packageAmount + this.packageSize = packageConfig.packageSize + additionalProperties(packageConfig.additionalProperties) } - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) - /** Rate per unit of usage */ - @JsonProperty("unit_amount") + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") @ExcludeMissing - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + 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 + */ + @JsonProperty("package_size") + @ExcludeMissing + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize } fun additionalProperties(additionalProperties: Map) = apply { @@ -2437,8 +4217,12 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): UnitConfig = - UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + fun build(): PackageConfig = + PackageConfig( + packageAmount, + packageSize, + additionalProperties.toUnmodifiable(), + ) } override fun equals(other: Any?): Boolean { @@ -2446,20 +4230,77 @@ private constructor( return true } - return /* spotless:off */ other is UnitConfig && this.unitAmount == other.unitAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageConfig && this.packageAmount == other.packageAmount && this.packageSize == other.packageSize && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(unitAmount, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(packageAmount, packageSize, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + } + + class PriceType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE_PRICE = PriceType(JsonField.of("usage_price")) + + @JvmField val FIXED_PRICE = PriceType(JsonField.of("fixed_price")) + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + fun asString(): String = _value().asStringOrThrow() } override fun equals(other: Any?): Boolean { @@ -2467,25 +4308,25 @@ private constructor( return true } - return /* spotless:off */ other is UnitPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.unitConfig == other.unitConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackagePrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.packageConfig == other.packageConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, unitConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, packageConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "UnitPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, unitConfig=$unitConfig, additionalProperties=$additionalProperties}" + "PackagePrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, packageConfig=$packageConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = PackagePrice.Builder::class) + @JsonDeserialize(builder = MatrixPrice.Builder::class) @NoAutoDetect - class PackagePrice + class MatrixPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -2509,7 +4350,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val packageConfig: JsonField, + private val matrixConfig: JsonField, private val additionalProperties: Map, ) { @@ -2576,7 +4417,7 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -2635,13 +4476,13 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("package_config") @ExcludeMissing fun _packageConfig() = packageConfig + @JsonProperty("matrix_config") @ExcludeMissing fun _matrixConfig() = matrixConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): PackagePrice = apply { + fun validate(): MatrixPrice = apply { if (!validated) { metadata().validate() id() @@ -2665,7 +4506,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - packageConfig().validate() + matrixConfig().validate() validated = true } } @@ -2703,35 +4544,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var packageConfig: JsonField = JsonMissing.of() + private var matrixConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(packagePrice: PackagePrice) = apply { - this.metadata = packagePrice.metadata - this.id = packagePrice.id - this.name = packagePrice.name - this.externalPriceId = packagePrice.externalPriceId - this.priceType = packagePrice.priceType - this.modelType = packagePrice.modelType - this.createdAt = packagePrice.createdAt - this.cadence = packagePrice.cadence - this.billingCycleConfiguration = packagePrice.billingCycleConfiguration - this.invoicingCycleConfiguration = packagePrice.invoicingCycleConfiguration - this.billableMetric = packagePrice.billableMetric - this.fixedPriceQuantity = packagePrice.fixedPriceQuantity - this.planPhaseOrder = packagePrice.planPhaseOrder - this.currency = packagePrice.currency - this.conversionRate = packagePrice.conversionRate - this.item = packagePrice.item - this.creditAllocation = packagePrice.creditAllocation - this.discount = packagePrice.discount - this.minimum = packagePrice.minimum - this.minimumAmount = packagePrice.minimumAmount - this.maximum = packagePrice.maximum - this.maximumAmount = packagePrice.maximumAmount - this.packageConfig = packagePrice.packageConfig - additionalProperties(packagePrice.additionalProperties) + internal fun from(matrixPrice: MatrixPrice) = apply { + this.metadata = matrixPrice.metadata + this.id = matrixPrice.id + this.name = matrixPrice.name + this.externalPriceId = matrixPrice.externalPriceId + this.priceType = matrixPrice.priceType + this.modelType = matrixPrice.modelType + this.createdAt = matrixPrice.createdAt + this.cadence = matrixPrice.cadence + this.billingCycleConfiguration = matrixPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = matrixPrice.invoicingCycleConfiguration + this.billableMetric = matrixPrice.billableMetric + this.fixedPriceQuantity = matrixPrice.fixedPriceQuantity + this.planPhaseOrder = matrixPrice.planPhaseOrder + this.currency = matrixPrice.currency + this.conversionRate = matrixPrice.conversionRate + this.item = matrixPrice.item + this.creditAllocation = matrixPrice.creditAllocation + this.discount = matrixPrice.discount + this.minimum = matrixPrice.minimum + this.minimumAmount = matrixPrice.minimumAmount + this.maximum = matrixPrice.maximum + this.maximumAmount = matrixPrice.maximumAmount + this.matrixConfig = matrixPrice.matrixConfig + additionalProperties(matrixPrice.additionalProperties) } /** @@ -2906,13 +4747,12 @@ private constructor( this.maximumAmount = maximumAmount } - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) + fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) - @JsonProperty("package_config") + @JsonProperty("matrix_config") @ExcludeMissing - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig } fun additionalProperties(additionalProperties: Map) = apply { @@ -2929,8 +4769,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PackagePrice = - PackagePrice( + fun build(): MatrixPrice = + MatrixPrice( metadata, id, name, @@ -2953,7 +4793,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - packageConfig, + matrixConfig, additionalProperties.toUnmodifiable(), ) } @@ -3680,46 +5520,47 @@ private constructor( "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Maximum.Builder::class) + @JsonDeserialize(builder = MatrixConfig.Builder::class) @NoAutoDetect - class Maximum + class MatrixConfig private constructor( - private val maximumAmount: JsonField, - private val appliesToPriceIds: JsonField>, + private val dimensions: JsonField>, + private val defaultUnitAmount: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") - /** - * 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") + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") - /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = matrixValues.getRequired("matrix_values") - /** - * 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") + /** One or two event property values to evaluate matrix groups by */ + @JsonProperty("dimensions") @ExcludeMissing fun _dimensions() = dimensions + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _defaultUnitAmount() = defaultUnitAmount + + /** Matrix values for specified matrix grouping keys */ + @JsonProperty("matrix_values") @ExcludeMissing fun _matrixValues() = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): Maximum = apply { + fun validate(): MatrixConfig = apply { if (!validated) { - maximumAmount() - appliesToPriceIds() + dimensions() + defaultUnitAmount() + matrixValues().forEach { it.validate() } validated = true } } @@ -3733,43 +5574,53 @@ private constructor( class Builder { - private var maximumAmount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var dimensions: JsonField> = JsonMissing.of() + private var defaultUnitAmount: JsonField = JsonMissing.of() + private var matrixValues: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - this.maximumAmount = maximum.maximumAmount - this.appliesToPriceIds = maximum.appliesToPriceIds - additionalProperties(maximum.additionalProperties) + internal fun from(matrixConfig: MatrixConfig) = apply { + this.dimensions = matrixConfig.dimensions + this.defaultUnitAmount = matrixConfig.defaultUnitAmount + this.matrixValues = matrixConfig.matrixValues + additionalProperties(matrixConfig.additionalProperties) } - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) - /** Maximum amount applied */ - @JsonProperty("maximum_amount") + /** One or two event property values to evaluate matrix groups by */ + @JsonProperty("dimensions") @ExcludeMissing - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions } /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. + * Default per unit rate for any usage not bucketed into a specified matrix_value */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. + * Default per unit rate for any usage not bucketed into a specified matrix_value */ - @JsonProperty("applies_to_price_ids") + @JsonProperty("default_unit_amount") @ExcludeMissing - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues } fun additionalProperties(additionalProperties: Map) = apply { @@ -3787,91 +5638,152 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Maximum = - Maximum( - maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, + fun build(): MatrixConfig = + MatrixConfig( + dimensions.map { it.toUnmodifiable() }, + defaultUnitAmount, + matrixValues.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable(), ) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonDeserialize(builder = MatrixValue.Builder::class) + @NoAutoDetect + class MatrixValue + private constructor( + private val unitAmount: JsonField, + private val dimensionValues: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** 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. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + + /** + * 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() = dimensionValues + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MatrixValue = apply { + if (!validated) { + unitAmount() + dimensionValues() + validated = true + } } - return /* spotless:off */ other is Maximum && this.maximumAmount == other.maximumAmount && this.appliesToPriceIds == other.appliesToPriceIds && this.additionalProperties == other.additionalProperties /* spotless:on */ - } + fun toBuilder() = Builder().from(this) - private var hashCode: Int = 0 + companion object { - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(maximumAmount, appliesToPriceIds, additionalProperties) /* spotless:on */ + @JvmStatic fun builder() = Builder() } - return hashCode - } - override fun toString() = - "Maximum{maximumAmount=$maximumAmount, appliesToPriceIds=$appliesToPriceIds, additionalProperties=$additionalProperties}" - } + class Builder { - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + private var unitAmount: JsonField = JsonMissing.of() + private var dimensionValues: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - private var validated: Boolean = false + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + this.unitAmount = matrixValue.unitAmount + this.dimensionValues = matrixValue.dimensionValues + additionalProperties(matrixValue.additionalProperties) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } + /** Unit price for the specified dimension_values */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun toBuilder() = Builder().from(this) + /** + * 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)) - companion object { + /** + * 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(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues + } - @JvmStatic fun builder() = Builder() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } - class Builder { + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - private var additionalProperties: MutableMap = mutableMapOf() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + fun build(): MatrixValue = + MatrixValue( + unitAmount, + dimensionValues.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + return /* spotless:off */ other is MatrixValue && this.unitAmount == other.unitAmount && this.dimensionValues == other.dimensionValues && this.additionalProperties == other.additionalProperties /* spotless:on */ } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(unitAmount, dimensionValues, additionalProperties) /* spotless:on */ } + return hashCode + } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + override fun toString() = + "MatrixValue{unitAmount=$unitAmount, dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3879,47 +5791,48 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixConfig && this.dimensions == other.dimensions && this.defaultUnitAmount == other.defaultUnitAmount && this.matrixValues == other.matrixValues && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(dimensions, defaultUnitAmount, matrixValues, additionalProperties) /* spotless:on */ } return hashCode } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "MatrixConfig{dimensions=$dimensions, defaultUnitAmount=$defaultUnitAmount, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Minimum.Builder::class) + @JsonDeserialize(builder = Maximum.Builder::class) @NoAutoDetect - class Minimum + class Maximum private constructor( - private val minimumAmount: JsonField, + private val maximumAmount: JsonField, private val appliesToPriceIds: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + /** Maximum amount applied */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, + * 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") - /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + /** Maximum amount applied */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, + * 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") @@ -3930,9 +5843,9 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): Minimum = apply { + fun validate(): Maximum = apply { if (!validated) { - minimumAmount() + maximumAmount() appliesToPriceIds() validated = true } @@ -3947,38 +5860,38 @@ private constructor( class Builder { - private var minimumAmount: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() private var appliesToPriceIds: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - this.minimumAmount = minimum.minimumAmount - this.appliesToPriceIds = minimum.appliesToPriceIds - additionalProperties(minimum.additionalProperties) + internal fun from(maximum: Maximum) = apply { + this.maximumAmount = maximum.maximumAmount + this.appliesToPriceIds = maximum.appliesToPriceIds + additionalProperties(maximum.additionalProperties) } - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) + /** Maximum amount applied */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) - /** Minimum amount applied */ - @JsonProperty("minimum_amount") + /** Maximum amount applied */ + @JsonProperty("maximum_amount") @ExcludeMissing - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. + * 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 minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. + * 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 @@ -4001,9 +5914,9 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Minimum = - Minimum( - minimumAmount, + fun build(): Maximum = + Maximum( + maximumAmount, appliesToPriceIds.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable(), ) @@ -4014,110 +5927,140 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && this.minimumAmount == other.minimumAmount && this.appliesToPriceIds == other.appliesToPriceIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && this.maximumAmount == other.maximumAmount && this.appliesToPriceIds == other.appliesToPriceIds && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(minimumAmount, appliesToPriceIds, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(maximumAmount, appliesToPriceIds, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Minimum{minimumAmount=$minimumAmount, appliesToPriceIds=$appliesToPriceIds, additionalProperties=$additionalProperties}" + "Maximum{maximumAmount=$maximumAmount, appliesToPriceIds=$appliesToPriceIds, additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata private constructor( - private val value: JsonField, - ) : Enum { + private val additionalProperties: Map, + ) { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + private var validated: Boolean = false - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true } + } - return /* spotless:off */ other is ModelType && this.value == other.value /* spotless:on */ + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() } - override fun hashCode() = value.hashCode() + class Builder { - override fun toString() = value.toString() + private var additionalProperties: MutableMap = mutableMapOf() - companion object { + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } - @JvmField val PACKAGE = ModelType(JsonField.of("package")) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - enum class Known { - PACKAGE, - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - enum class Value { - PACKAGE, - _UNKNOWN, + fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ } + return hashCode + } - fun asString(): String = _value().asStringOrThrow() + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = PackageConfig.Builder::class) + @JsonDeserialize(builder = Minimum.Builder::class) @NoAutoDetect - class PackageConfig + class Minimum private constructor( - private val packageAmount: JsonField, - private val packageSize: JsonField, + private val minimumAmount: JsonField, + private val appliesToPriceIds: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") + /** Minimum amount applied */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, + * this can be a subset of prices. */ - fun packageSize(): Long = packageSize.getRequired("package_size") + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") @ExcludeMissing fun _packageAmount() = packageAmount + /** Minimum amount applied */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, + * this can be a subset of prices. */ - @JsonProperty("package_size") @ExcludeMissing fun _packageSize() = packageSize + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): PackageConfig = apply { + fun validate(): Minimum = apply { if (!validated) { - packageAmount() - packageSize() + minimumAmount() + appliesToPriceIds() validated = true } } @@ -4131,42 +6074,43 @@ private constructor( class Builder { - private var packageAmount: JsonField = JsonMissing.of() - private var packageSize: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - this.packageAmount = packageConfig.packageAmount - this.packageSize = packageConfig.packageSize - additionalProperties(packageConfig.additionalProperties) + internal fun from(minimum: Minimum) = apply { + this.minimumAmount = minimum.minimumAmount + this.appliesToPriceIds = minimum.appliesToPriceIds + additionalProperties(minimum.additionalProperties) } - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) + /** Minimum amount applied */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") + /** Minimum amount applied */ + @JsonProperty("minimum_amount") @ExcludeMissing - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. */ - @JsonProperty("package_size") + @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds } fun additionalProperties(additionalProperties: Map) = apply { @@ -4184,10 +6128,10 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PackageConfig = - PackageConfig( - packageAmount, - packageSize, + fun build(): Minimum = + Minimum( + minimumAmount, + appliesToPriceIds.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable(), ) } @@ -4197,20 +6141,71 @@ private constructor( return true } - return /* spotless:off */ other is PackageConfig && this.packageAmount == other.packageAmount && this.packageSize == other.packageSize && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && this.minimumAmount == other.minimumAmount && this.appliesToPriceIds == other.appliesToPriceIds && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(packageAmount, packageSize, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(minimumAmount, appliesToPriceIds, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" + "Minimum{minimumAmount=$minimumAmount, appliesToPriceIds=$appliesToPriceIds, additionalProperties=$additionalProperties}" + } + + class ModelType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MATRIX = ModelType(JsonField.of("matrix")) + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + enum class Known { + MATRIX, + } + + enum class Value { + MATRIX, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MATRIX -> Value.MATRIX + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MATRIX -> Known.MATRIX + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + fun asString(): String = _value().asStringOrThrow() } class PriceType @@ -4275,25 +6270,25 @@ private constructor( return true } - return /* spotless:off */ other is PackagePrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.packageConfig == other.packageConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.matrixConfig == other.matrixConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, packageConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, matrixConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "PackagePrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, packageConfig=$packageConfig, additionalProperties=$additionalProperties}" + "MatrixPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, matrixConfig=$matrixConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = MatrixPrice.Builder::class) + @JsonDeserialize(builder = TieredPrice.Builder::class) @NoAutoDetect - class MatrixPrice + class TieredPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -4317,7 +6312,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val matrixConfig: JsonField, + private val tieredConfig: JsonField, private val additionalProperties: Map, ) { @@ -4384,7 +6379,7 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -4443,13 +6438,13 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("matrix_config") @ExcludeMissing fun _matrixConfig() = matrixConfig + @JsonProperty("tiered_config") @ExcludeMissing fun _tieredConfig() = tieredConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): MatrixPrice = apply { + fun validate(): TieredPrice = apply { if (!validated) { metadata().validate() id() @@ -4473,7 +6468,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - matrixConfig().validate() + tieredConfig().validate() validated = true } } @@ -4511,35 +6506,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var matrixConfig: JsonField = JsonMissing.of() + private var tieredConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixPrice: MatrixPrice) = apply { - this.metadata = matrixPrice.metadata - this.id = matrixPrice.id - this.name = matrixPrice.name - this.externalPriceId = matrixPrice.externalPriceId - this.priceType = matrixPrice.priceType - this.modelType = matrixPrice.modelType - this.createdAt = matrixPrice.createdAt - this.cadence = matrixPrice.cadence - this.billingCycleConfiguration = matrixPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = matrixPrice.invoicingCycleConfiguration - this.billableMetric = matrixPrice.billableMetric - this.fixedPriceQuantity = matrixPrice.fixedPriceQuantity - this.planPhaseOrder = matrixPrice.planPhaseOrder - this.currency = matrixPrice.currency - this.conversionRate = matrixPrice.conversionRate - this.item = matrixPrice.item - this.creditAllocation = matrixPrice.creditAllocation - this.discount = matrixPrice.discount - this.minimum = matrixPrice.minimum - this.minimumAmount = matrixPrice.minimumAmount - this.maximum = matrixPrice.maximum - this.maximumAmount = matrixPrice.maximumAmount - this.matrixConfig = matrixPrice.matrixConfig - additionalProperties(matrixPrice.additionalProperties) + internal fun from(tieredPrice: TieredPrice) = apply { + this.metadata = tieredPrice.metadata + this.id = tieredPrice.id + this.name = tieredPrice.name + this.externalPriceId = tieredPrice.externalPriceId + this.priceType = tieredPrice.priceType + this.modelType = tieredPrice.modelType + this.createdAt = tieredPrice.createdAt + this.cadence = tieredPrice.cadence + this.billingCycleConfiguration = tieredPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = tieredPrice.invoicingCycleConfiguration + this.billableMetric = tieredPrice.billableMetric + this.fixedPriceQuantity = tieredPrice.fixedPriceQuantity + this.planPhaseOrder = tieredPrice.planPhaseOrder + this.currency = tieredPrice.currency + this.conversionRate = tieredPrice.conversionRate + this.item = tieredPrice.item + this.creditAllocation = tieredPrice.creditAllocation + this.discount = tieredPrice.discount + this.minimum = tieredPrice.minimum + this.minimumAmount = tieredPrice.minimumAmount + this.maximum = tieredPrice.maximum + this.maximumAmount = tieredPrice.maximumAmount + this.tieredConfig = tieredPrice.tieredConfig + additionalProperties(tieredPrice.additionalProperties) } /** @@ -4714,12 +6709,12 @@ private constructor( this.maximumAmount = maximumAmount } - fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) + fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) - @JsonProperty("matrix_config") + @JsonProperty("tiered_config") @ExcludeMissing - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig } fun additionalProperties(additionalProperties: Map) = apply { @@ -4736,8 +6731,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MatrixPrice = - MatrixPrice( + fun build(): TieredPrice = + TieredPrice( metadata, id, name, @@ -4760,7 +6755,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - matrixConfig, + tieredConfig, additionalProperties.toUnmodifiable(), ) } @@ -5487,293 +7482,6 @@ private constructor( "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = MatrixConfig.Builder::class) - @NoAutoDetect - class MatrixConfig - private constructor( - private val dimensions: JsonField>, - private val defaultUnitAmount: JsonField, - private val matrixValues: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = matrixValues.getRequired("matrix_values") - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") @ExcludeMissing fun _dimensions() = dimensions - - /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount() = defaultUnitAmount - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") @ExcludeMissing fun _matrixValues() = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MatrixConfig = apply { - if (!validated) { - dimensions() - defaultUnitAmount() - matrixValues().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var dimensions: JsonField> = JsonMissing.of() - private var defaultUnitAmount: JsonField = JsonMissing.of() - private var matrixValues: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - this.dimensions = matrixConfig.dimensions - this.defaultUnitAmount = matrixConfig.defaultUnitAmount - this.matrixValues = matrixConfig.matrixValues - additionalProperties(matrixConfig.additionalProperties) - } - - /** 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 */ - @JsonProperty("dimensions") - @ExcludeMissing - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions - } - - /** - * 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 - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { - this.defaultUnitAmount = defaultUnitAmount - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MatrixConfig = - MatrixConfig( - dimensions.map { it.toUnmodifiable() }, - defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = MatrixValue.Builder::class) - @NoAutoDetect - class MatrixValue - private constructor( - private val unitAmount: JsonField, - private val dimensionValues: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** 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. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount - - /** - * 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() = dimensionValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MatrixValue = apply { - if (!validated) { - unitAmount() - dimensionValues() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var unitAmount: JsonField = JsonMissing.of() - private var dimensionValues: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - this.unitAmount = matrixValue.unitAmount - this.dimensionValues = matrixValue.dimensionValues - additionalProperties(matrixValue.additionalProperties) - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * 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. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MatrixValue = - MatrixValue( - unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && this.unitAmount == other.unitAmount && this.dimensionValues == other.dimensionValues && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(unitAmount, dimensionValues, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "MatrixValue{unitAmount=$unitAmount, dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && this.dimensions == other.dimensions && this.defaultUnitAmount == other.defaultUnitAmount && this.matrixValues == other.matrixValues && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(dimensions, defaultUnitAmount, matrixValues, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "MatrixConfig{dimensions=$dimensions, defaultUnitAmount=$defaultUnitAmount, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - @JsonDeserialize(builder = Maximum.Builder::class) @NoAutoDetect class Maximum @@ -6146,29 +7854,29 @@ private constructor( companion object { - @JvmField val MATRIX = ModelType(JsonField.of("matrix")) + @JvmField val TIERED = ModelType(JsonField.of("tiered")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - MATRIX, + TIERED, } enum class Value { - MATRIX, + TIERED, _UNKNOWN, } fun value(): Value = when (this) { - MATRIX -> Value.MATRIX + TIERED -> Value.TIERED else -> Value._UNKNOWN } fun known(): Known = when (this) { - MATRIX -> Known.MATRIX + TIERED -> Known.TIERED else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -6232,30 +7940,265 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + @JsonDeserialize(builder = TieredConfig.Builder::class) + @NoAutoDetect + class TieredConfig + private constructor( + private val tiers: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** 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() = tiers + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TieredConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var tiers: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredConfig: TieredConfig) = apply { + this.tiers = tieredConfig.tiers + additionalProperties(tieredConfig.additionalProperties) + } + + /** 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 */ + @JsonProperty("tiers") + @ExcludeMissing + fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TieredConfig = + TieredConfig( + tiers.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Tier.Builder::class) + @NoAutoDetect + class Tier + private constructor( + private val firstUnit: JsonField, + private val lastUnit: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** Inclusive tier starting value */ + fun firstUnit(): Double = firstUnit.getRequired("first_unit") + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(): Optional = + Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Amount per unit */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit() = firstUnit + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit() = lastUnit + + /** Amount per unit */ + @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Tier = apply { + if (!validated) { + firstUnit() + lastUnit() + unitAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var firstUnit: JsonField = JsonMissing.of() + private var lastUnit: JsonField = JsonMissing.of() + private var unitAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + this.firstUnit = tier.firstUnit + this.lastUnit = tier.lastUnit + this.unitAmount = tier.unitAmount + additionalProperties(tier.additionalProperties) + } + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") + @ExcludeMissing + fun firstUnit(firstUnit: JsonField) = apply { + this.firstUnit = firstUnit + } + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(lastUnit: Double) = lastUnit(JsonField.of(lastUnit)) + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + @JsonProperty("last_unit") + @ExcludeMissing + fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Tier = + Tier( + firstUnit, + lastUnit, + unitAmount, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tier && this.firstUnit == other.firstUnit && this.lastUnit == other.lastUnit && this.unitAmount == other.unitAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Tier{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredConfig && this.tiers == other.tiers && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(tiers, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MatrixPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.matrixConfig == other.matrixConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredConfig == other.tieredConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, matrixConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "MatrixPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, matrixConfig=$matrixConfig, additionalProperties=$additionalProperties}" + "TieredPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredConfig=$tieredConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = TieredPrice.Builder::class) + @JsonDeserialize(builder = TieredBpsPrice.Builder::class) @NoAutoDetect - class TieredPrice + class TieredBpsPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -6279,7 +8222,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val tieredConfig: JsonField, + private val tieredBpsConfig: JsonField, private val additionalProperties: Map, ) { @@ -6346,7 +8289,7 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -6405,13 +8348,13 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("tiered_config") @ExcludeMissing fun _tieredConfig() = tieredConfig + @JsonProperty("tiered_bps_config") @ExcludeMissing fun _tieredBpsConfig() = tieredBpsConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredPrice = apply { + fun validate(): TieredBpsPrice = apply { if (!validated) { metadata().validate() id() @@ -6435,7 +8378,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - tieredConfig().validate() + tieredBpsConfig().validate() validated = true } } @@ -6473,35 +8416,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var tieredConfig: JsonField = JsonMissing.of() + private var tieredBpsConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPrice: TieredPrice) = apply { - this.metadata = tieredPrice.metadata - this.id = tieredPrice.id - this.name = tieredPrice.name - this.externalPriceId = tieredPrice.externalPriceId - this.priceType = tieredPrice.priceType - this.modelType = tieredPrice.modelType - this.createdAt = tieredPrice.createdAt - this.cadence = tieredPrice.cadence - this.billingCycleConfiguration = tieredPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = tieredPrice.invoicingCycleConfiguration - this.billableMetric = tieredPrice.billableMetric - this.fixedPriceQuantity = tieredPrice.fixedPriceQuantity - this.planPhaseOrder = tieredPrice.planPhaseOrder - this.currency = tieredPrice.currency - this.conversionRate = tieredPrice.conversionRate - this.item = tieredPrice.item - this.creditAllocation = tieredPrice.creditAllocation - this.discount = tieredPrice.discount - this.minimum = tieredPrice.minimum - this.minimumAmount = tieredPrice.minimumAmount - this.maximum = tieredPrice.maximum - this.maximumAmount = tieredPrice.maximumAmount - this.tieredConfig = tieredPrice.tieredConfig - additionalProperties(tieredPrice.additionalProperties) + internal fun from(tieredBpsPrice: TieredBpsPrice) = apply { + this.metadata = tieredBpsPrice.metadata + this.id = tieredBpsPrice.id + this.name = tieredBpsPrice.name + this.externalPriceId = tieredBpsPrice.externalPriceId + this.priceType = tieredBpsPrice.priceType + this.modelType = tieredBpsPrice.modelType + this.createdAt = tieredBpsPrice.createdAt + this.cadence = tieredBpsPrice.cadence + this.billingCycleConfiguration = tieredBpsPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = tieredBpsPrice.invoicingCycleConfiguration + this.billableMetric = tieredBpsPrice.billableMetric + this.fixedPriceQuantity = tieredBpsPrice.fixedPriceQuantity + this.planPhaseOrder = tieredBpsPrice.planPhaseOrder + this.currency = tieredBpsPrice.currency + this.conversionRate = tieredBpsPrice.conversionRate + this.item = tieredBpsPrice.item + this.creditAllocation = tieredBpsPrice.creditAllocation + this.discount = tieredBpsPrice.discount + this.minimum = tieredBpsPrice.minimum + this.minimumAmount = tieredBpsPrice.minimumAmount + this.maximum = tieredBpsPrice.maximum + this.maximumAmount = tieredBpsPrice.maximumAmount + this.tieredBpsConfig = tieredBpsPrice.tieredBpsConfig + additionalProperties(tieredBpsPrice.additionalProperties) } /** @@ -6676,12 +8619,13 @@ private constructor( this.maximumAmount = maximumAmount } - fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) - @JsonProperty("tiered_config") + @JsonProperty("tiered_bps_config") @ExcludeMissing - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { + this.tieredBpsConfig = tieredBpsConfig } fun additionalProperties(additionalProperties: Map) = apply { @@ -6698,8 +8642,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredPrice = - TieredPrice( + fun build(): TieredBpsPrice = + TieredBpsPrice( metadata, id, name, @@ -6722,7 +8666,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - tieredConfig, + tieredBpsConfig, additionalProperties.toUnmodifiable(), ) } @@ -7821,29 +9765,29 @@ private constructor( companion object { - @JvmField val TIERED = ModelType(JsonField.of("tiered")) + @JvmField val TIERED_BPS = ModelType(JsonField.of("tiered_bps")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - TIERED, + TIERED_BPS, } enum class Value { - TIERED, + TIERED_BPS, _UNKNOWN, } fun value(): Value = when (this) { - TIERED -> Value.TIERED + TIERED_BPS -> Value.TIERED_BPS else -> Value._UNKNOWN } fun known(): Known = when (this) { - TIERED -> Known.TIERED + TIERED_BPS -> Known.TIERED_BPS else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -7907,9 +9851,9 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = TieredConfig.Builder::class) + @JsonDeserialize(builder = TieredBpsConfig.Builder::class) @NoAutoDetect - class TieredConfig + class TieredBpsConfig private constructor( private val tiers: JsonField>, private val additionalProperties: Map, @@ -7917,17 +9861,21 @@ private constructor( private var validated: Boolean = false - /** Tiers for rating based on total usage quantities into the specified tier */ + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers + */ fun tiers(): List = tiers.getRequired("tiers") - /** Tiers for rating based on total usage quantities into the specified tier */ + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers + */ @JsonProperty("tiers") @ExcludeMissing fun _tiers() = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredConfig = apply { + fun validate(): TieredBpsConfig = apply { if (!validated) { tiers().forEach { it.validate() } validated = true @@ -7947,15 +9895,21 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - this.tiers = tieredConfig.tiers - additionalProperties(tieredConfig.additionalProperties) + internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { + this.tiers = tieredBpsConfig.tiers + additionalProperties(tieredBpsConfig.additionalProperties) } - /** Tiers for rating based on total usage quantities into the specified tier */ + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified + * tiers + */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** Tiers for rating based on total usage quantities into the specified tier */ + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified + * tiers + */ @JsonProperty("tiers") @ExcludeMissing fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } @@ -7975,8 +9929,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredConfig = - TieredConfig( + fun build(): TieredBpsConfig = + TieredBpsConfig( tiers.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable() ) @@ -7986,32 +9940,42 @@ private constructor( @NoAutoDetect class Tier private constructor( - private val firstUnit: JsonField, - private val lastUnit: JsonField, - private val unitAmount: JsonField, + private val minimumAmount: JsonField, + private val maximumAmount: JsonField, + private val bps: JsonField, + private val perUnitMaximum: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** Per-event basis point rate */ + fun bps(): Double = bps.getRequired("bps") + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) /** Inclusive tier starting value */ - @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit() = firstUnit + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount - /** Exclusive tier ending value. If null, this is treated as the last tier */ - @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit() = lastUnit + /** Exclusive tier ending value */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - /** Amount per unit */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps() = bps + + /** Per unit maximum to charge */ + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun _perUnitMaximum() = perUnitMaximum @JsonAnyGetter @ExcludeMissing @@ -8019,9 +9983,10 @@ private constructor( fun validate(): Tier = apply { if (!validated) { - firstUnit() - lastUnit() - unitAmount() + minimumAmount() + maximumAmount() + bps() + perUnitMaximum() validated = true } } @@ -8035,45 +10000,60 @@ private constructor( class Builder { - private var firstUnit: JsonField = JsonMissing.of() - private var lastUnit: JsonField = JsonMissing.of() - private var unitAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var bps: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tier: Tier) = apply { - this.firstUnit = tier.firstUnit - this.lastUnit = tier.lastUnit - this.unitAmount = tier.unitAmount + this.minimumAmount = tier.minimumAmount + this.maximumAmount = tier.maximumAmount + this.bps = tier.bps + this.perUnitMaximum = tier.perUnitMaximum additionalProperties(tier.additionalProperties) } /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) /** Inclusive tier starting value */ - @JsonProperty("first_unit") + @JsonProperty("minimum_amount") @ExcludeMissing - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(lastUnit: Double) = lastUnit(JsonField.of(lastUnit)) + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) - /** Exclusive tier ending value. If null, this is treated as the last tier */ - @JsonProperty("last_unit") + /** Exclusive tier ending value */ + @JsonProperty("maximum_amount") @ExcludeMissing - fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** Per-event basis point rate */ + fun bps(bps: Double) = bps(JsonField.of(bps)) - /** Amount per unit */ - @JsonProperty("unit_amount") + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String) = + perUnitMaximum(JsonField.of(perUnitMaximum)) + + /** Per unit maximum to charge */ + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum } fun additionalProperties(additionalProperties: Map) = apply { @@ -8093,9 +10073,10 @@ private constructor( fun build(): Tier = Tier( - firstUnit, - lastUnit, - unitAmount, + minimumAmount, + maximumAmount, + bps, + perUnitMaximum, additionalProperties.toUnmodifiable(), ) } @@ -8105,20 +10086,20 @@ private constructor( return true } - return /* spotless:off */ other is Tier && this.firstUnit == other.firstUnit && this.lastUnit == other.lastUnit && this.unitAmount == other.unitAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tier && this.minimumAmount == other.minimumAmount && this.maximumAmount == other.maximumAmount && this.bps == other.bps && this.perUnitMaximum == other.perUnitMaximum && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(minimumAmount, maximumAmount, bps, perUnitMaximum, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Tier{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "Tier{minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -8126,7 +10107,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredConfig && this.tiers == other.tiers && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBpsConfig && this.tiers == other.tiers && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -8139,7 +10120,7 @@ private constructor( } override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -8147,25 +10128,25 @@ private constructor( return true } - return /* spotless:off */ other is TieredPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredConfig == other.tieredConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBpsPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredBpsConfig == other.tieredBpsConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredBpsConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "TieredPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredConfig=$tieredConfig, additionalProperties=$additionalProperties}" + "TieredBpsPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredBpsConfig=$tieredBpsConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = TieredBpsPrice.Builder::class) + @JsonDeserialize(builder = BpsPrice.Builder::class) @NoAutoDetect - class TieredBpsPrice + class BpsPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -8189,7 +10170,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val tieredBpsConfig: JsonField, + private val bpsConfig: JsonField, private val additionalProperties: Map, ) { @@ -8256,7 +10237,7 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") + fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -8315,13 +10296,13 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("tiered_bps_config") @ExcludeMissing fun _tieredBpsConfig() = tieredBpsConfig + @JsonProperty("bps_config") @ExcludeMissing fun _bpsConfig() = bpsConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredBpsPrice = apply { + fun validate(): BpsPrice = apply { if (!validated) { metadata().validate() id() @@ -8345,7 +10326,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - tieredBpsConfig().validate() + bpsConfig().validate() validated = true } } @@ -8383,35 +10364,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var tieredBpsConfig: JsonField = JsonMissing.of() + private var bpsConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredBpsPrice: TieredBpsPrice) = apply { - this.metadata = tieredBpsPrice.metadata - this.id = tieredBpsPrice.id - this.name = tieredBpsPrice.name - this.externalPriceId = tieredBpsPrice.externalPriceId - this.priceType = tieredBpsPrice.priceType - this.modelType = tieredBpsPrice.modelType - this.createdAt = tieredBpsPrice.createdAt - this.cadence = tieredBpsPrice.cadence - this.billingCycleConfiguration = tieredBpsPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = tieredBpsPrice.invoicingCycleConfiguration - this.billableMetric = tieredBpsPrice.billableMetric - this.fixedPriceQuantity = tieredBpsPrice.fixedPriceQuantity - this.planPhaseOrder = tieredBpsPrice.planPhaseOrder - this.currency = tieredBpsPrice.currency - this.conversionRate = tieredBpsPrice.conversionRate - this.item = tieredBpsPrice.item - this.creditAllocation = tieredBpsPrice.creditAllocation - this.discount = tieredBpsPrice.discount - this.minimum = tieredBpsPrice.minimum - this.minimumAmount = tieredBpsPrice.minimumAmount - this.maximum = tieredBpsPrice.maximum - this.maximumAmount = tieredBpsPrice.maximumAmount - this.tieredBpsConfig = tieredBpsPrice.tieredBpsConfig - additionalProperties(tieredBpsPrice.additionalProperties) + internal fun from(bpsPrice: BpsPrice) = apply { + this.metadata = bpsPrice.metadata + this.id = bpsPrice.id + this.name = bpsPrice.name + this.externalPriceId = bpsPrice.externalPriceId + this.priceType = bpsPrice.priceType + this.modelType = bpsPrice.modelType + this.createdAt = bpsPrice.createdAt + this.cadence = bpsPrice.cadence + this.billingCycleConfiguration = bpsPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = bpsPrice.invoicingCycleConfiguration + this.billableMetric = bpsPrice.billableMetric + this.fixedPriceQuantity = bpsPrice.fixedPriceQuantity + this.planPhaseOrder = bpsPrice.planPhaseOrder + this.currency = bpsPrice.currency + this.conversionRate = bpsPrice.conversionRate + this.item = bpsPrice.item + this.creditAllocation = bpsPrice.creditAllocation + this.discount = bpsPrice.discount + this.minimum = bpsPrice.minimum + this.minimumAmount = bpsPrice.minimumAmount + this.maximum = bpsPrice.maximum + this.maximumAmount = bpsPrice.maximumAmount + this.bpsConfig = bpsPrice.bpsConfig + additionalProperties(bpsPrice.additionalProperties) } /** @@ -8586,14 +10567,11 @@ private constructor( this.maximumAmount = maximumAmount } - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) + fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - @JsonProperty("tiered_bps_config") + @JsonProperty("bps_config") @ExcludeMissing - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } + fun bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8609,8 +10587,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredBpsPrice = - TieredBpsPrice( + fun build(): BpsPrice = + BpsPrice( metadata, id, name, @@ -8633,7 +10611,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - tieredBpsConfig, + bpsConfig, additionalProperties.toUnmodifiable(), ) } @@ -8894,6 +10872,125 @@ private constructor( "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" } + @JsonDeserialize(builder = BpsConfig.Builder::class) + @NoAutoDetect + class BpsConfig + private constructor( + private val bps: JsonField, + private val perUnitMaximum: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** 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() = bps + + /** Optional currency amount maximum to cap spend per event */ + @JsonProperty("per_unit_maximum") @ExcludeMissing fun _perUnitMaximum() = perUnitMaximum + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BpsConfig = apply { + if (!validated) { + bps() + perUnitMaximum() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var bps: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bpsConfig: BpsConfig) = apply { + this.bps = bpsConfig.bps + this.perUnitMaximum = bpsConfig.perUnitMaximum + additionalProperties(bpsConfig.additionalProperties) + } + + /** Basis point take rate per event */ + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + @JsonProperty("bps") + @ExcludeMissing + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: String) = + perUnitMaximum(JsonField.of(perUnitMaximum)) + + /** Optional currency amount maximum to cap spend per event */ + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BpsConfig = + BpsConfig( + bps, + perUnitMaximum, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BpsConfig && this.bps == other.bps && this.perUnitMaximum == other.perUnitMaximum && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(bps, perUnitMaximum, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" + } + class Cadence @JsonCreator private constructor( @@ -9732,29 +11829,29 @@ private constructor( companion object { - @JvmField val TIERED_BPS = ModelType(JsonField.of("tiered_bps")) + @JvmField val BPS = ModelType(JsonField.of("bps")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - TIERED_BPS, + BPS, } enum class Value { - TIERED_BPS, + BPS, _UNKNOWN, } fun value(): Value = when (this) { - TIERED_BPS -> Value.TIERED_BPS + BPS -> Value.BPS else -> Value._UNKNOWN } fun known(): Known = when (this) { - TIERED_BPS -> Known.TIERED_BPS + BPS -> Known.BPS else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -9818,302 +11915,30 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = TieredBpsConfig.Builder::class) - @NoAutoDetect - class TieredBpsConfig - private constructor( - private val tiers: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** - * 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() = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TieredBpsConfig = apply { - if (!validated) { - tiers().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var tiers: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - this.tiers = tieredBpsConfig.tiers - additionalProperties(tieredBpsConfig.additionalProperties) - } - - /** - * 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 - */ - @JsonProperty("tiers") - @ExcludeMissing - fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } - - @JsonDeserialize(builder = Tier.Builder::class) - @NoAutoDetect - class Tier - private constructor( - private val minimumAmount: JsonField, - private val maximumAmount: JsonField, - private val bps: JsonField, - private val perUnitMaximum: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** 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-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps() = bps - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum() = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Tier = apply { - if (!validated) { - minimumAmount() - maximumAmount() - bps() - perUnitMaximum() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var minimumAmount: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var bps: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - this.minimumAmount = tier.minimumAmount - this.maximumAmount = tier.maximumAmount - this.bps = tier.bps - this.perUnitMaximum = tier.perUnitMaximum - additionalProperties(tier.additionalProperties) - } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - @JsonProperty("bps") - @ExcludeMissing - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String) = - perUnitMaximum(JsonField.of(perUnitMaximum)) - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Tier = - Tier( - minimumAmount, - maximumAmount, - bps, - perUnitMaximum, - additionalProperties.toUnmodifiable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && this.minimumAmount == other.minimumAmount && this.maximumAmount == other.maximumAmount && this.bps == other.bps && this.perUnitMaximum == other.perUnitMaximum && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(minimumAmount, maximumAmount, bps, perUnitMaximum, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Tier{minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && this.tiers == other.tiers && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(tiers, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is TieredBpsPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredBpsConfig == other.tieredBpsConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BpsPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.bpsConfig == other.bpsConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredBpsConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, bpsConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "TieredBpsPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredBpsConfig=$tieredBpsConfig, additionalProperties=$additionalProperties}" + "BpsPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, bpsConfig=$bpsConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = BpsPrice.Builder::class) + @JsonDeserialize(builder = BulkBpsPrice.Builder::class) @NoAutoDetect - class BpsPrice + class BulkBpsPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -10137,7 +11962,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val bpsConfig: JsonField, + private val bulkBpsConfig: JsonField, private val additionalProperties: Map, ) { @@ -10204,7 +12029,7 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") + fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -10263,13 +12088,13 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("bps_config") @ExcludeMissing fun _bpsConfig() = bpsConfig + @JsonProperty("bulk_bps_config") @ExcludeMissing fun _bulkBpsConfig() = bulkBpsConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): BpsPrice = apply { + fun validate(): BulkBpsPrice = apply { if (!validated) { metadata().validate() id() @@ -10293,7 +12118,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - bpsConfig().validate() + bulkBpsConfig().validate() validated = true } } @@ -10331,35 +12156,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var bpsConfig: JsonField = JsonMissing.of() + private var bulkBpsConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bpsPrice: BpsPrice) = apply { - this.metadata = bpsPrice.metadata - this.id = bpsPrice.id - this.name = bpsPrice.name - this.externalPriceId = bpsPrice.externalPriceId - this.priceType = bpsPrice.priceType - this.modelType = bpsPrice.modelType - this.createdAt = bpsPrice.createdAt - this.cadence = bpsPrice.cadence - this.billingCycleConfiguration = bpsPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = bpsPrice.invoicingCycleConfiguration - this.billableMetric = bpsPrice.billableMetric - this.fixedPriceQuantity = bpsPrice.fixedPriceQuantity - this.planPhaseOrder = bpsPrice.planPhaseOrder - this.currency = bpsPrice.currency - this.conversionRate = bpsPrice.conversionRate - this.item = bpsPrice.item - this.creditAllocation = bpsPrice.creditAllocation - this.discount = bpsPrice.discount - this.minimum = bpsPrice.minimum - this.minimumAmount = bpsPrice.minimumAmount - this.maximum = bpsPrice.maximum - this.maximumAmount = bpsPrice.maximumAmount - this.bpsConfig = bpsPrice.bpsConfig - additionalProperties(bpsPrice.additionalProperties) + internal fun from(bulkBpsPrice: BulkBpsPrice) = apply { + this.metadata = bulkBpsPrice.metadata + this.id = bulkBpsPrice.id + this.name = bulkBpsPrice.name + this.externalPriceId = bulkBpsPrice.externalPriceId + this.priceType = bulkBpsPrice.priceType + this.modelType = bulkBpsPrice.modelType + this.createdAt = bulkBpsPrice.createdAt + this.cadence = bulkBpsPrice.cadence + this.billingCycleConfiguration = bulkBpsPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = bulkBpsPrice.invoicingCycleConfiguration + this.billableMetric = bulkBpsPrice.billableMetric + this.fixedPriceQuantity = bulkBpsPrice.fixedPriceQuantity + this.planPhaseOrder = bulkBpsPrice.planPhaseOrder + this.currency = bulkBpsPrice.currency + this.conversionRate = bulkBpsPrice.conversionRate + this.item = bulkBpsPrice.item + this.creditAllocation = bulkBpsPrice.creditAllocation + this.discount = bulkBpsPrice.discount + this.minimum = bulkBpsPrice.minimum + this.minimumAmount = bulkBpsPrice.minimumAmount + this.maximum = bulkBpsPrice.maximum + this.maximumAmount = bulkBpsPrice.maximumAmount + this.bulkBpsConfig = bulkBpsPrice.bulkBpsConfig + additionalProperties(bulkBpsPrice.additionalProperties) } /** @@ -10534,11 +12359,14 @@ private constructor( this.maximumAmount = maximumAmount } - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) - @JsonProperty("bps_config") + @JsonProperty("bulk_bps_config") @ExcludeMissing - fun bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { + this.bulkBpsConfig = bulkBpsConfig + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10554,8 +12382,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BpsPrice = - BpsPrice( + fun build(): BulkBpsPrice = + BulkBpsPrice( metadata, id, name, @@ -10578,7 +12406,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - bpsConfig, + bulkBpsConfig, additionalProperties.toUnmodifiable(), ) } @@ -10839,38 +12667,35 @@ private constructor( "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = BpsConfig.Builder::class) + @JsonDeserialize(builder = BulkBpsConfig.Builder::class) @NoAutoDetect - class BpsConfig + class BulkBpsConfig private constructor( - private val bps: JsonField, - private val perUnitMaximum: JsonField, + private val tiers: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false - /** 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() = bps + /** + * 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") - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") @ExcludeMissing fun _perUnitMaximum() = perUnitMaximum + /** + * 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() = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): BpsConfig = apply { + fun validate(): BulkBpsConfig = apply { if (!validated) { - bps() - perUnitMaximum() + tiers().forEach { it.validate() } validated = true } } @@ -10884,35 +12709,28 @@ private constructor( class Builder { - private var bps: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() + private var tiers: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - this.bps = bpsConfig.bps - this.perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties(bpsConfig.additionalProperties) + internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { + this.tiers = bulkBpsConfig.tiers + additionalProperties(bulkBpsConfig.additionalProperties) } - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - @JsonProperty("bps") - @ExcludeMissing - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String) = - perUnitMaximum(JsonField.of(perUnitMaximum)) + /** + * 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)) - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier + * based on total volume + */ + @JsonProperty("tiers") @ExcludeMissing - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } + fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10929,33 +12747,176 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BpsConfig = - BpsConfig( - bps, - perUnitMaximum, - additionalProperties.toUnmodifiable(), + fun build(): BulkBpsConfig = + BulkBpsConfig( + tiers.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() ) } + @JsonDeserialize(builder = Tier.Builder::class) + @NoAutoDetect + class Tier + private constructor( + private val maximumAmount: JsonField, + private val bps: JsonField, + private val perUnitMaximum: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Basis points to rate on */ + fun bps(): Double = bps.getRequired("bps") + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Upper bound for tier */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps() = bps + + /** The maximum amount to charge for any one event */ + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun _perUnitMaximum() = perUnitMaximum + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Tier = apply { + if (!validated) { + maximumAmount() + bps() + perUnitMaximum() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var maximumAmount: JsonField = JsonMissing.of() + private var bps: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + this.maximumAmount = tier.maximumAmount + this.bps = tier.bps + this.perUnitMaximum = tier.perUnitMaximum + additionalProperties(tier.additionalProperties) + } + + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) + + /** Upper bound for tier */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** Basis points to rate on */ + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + @JsonProperty("bps") + @ExcludeMissing + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String) = + perUnitMaximum(JsonField.of(perUnitMaximum)) + + /** The maximum amount to charge for any one event */ + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Tier = + Tier( + maximumAmount, + bps, + perUnitMaximum, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tier && this.maximumAmount == other.maximumAmount && this.bps == other.bps && this.perUnitMaximum == other.perUnitMaximum && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(maximumAmount, bps, perUnitMaximum, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Tier{maximumAmount=$maximumAmount, bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BpsConfig && this.bps == other.bps && this.perUnitMaximum == other.perUnitMaximum && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBpsConfig && this.tiers == other.tiers && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(bps, perUnitMaximum, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(tiers, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" + "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } class Cadence @@ -11796,29 +13757,29 @@ private constructor( companion object { - @JvmField val BPS = ModelType(JsonField.of("bps")) + @JvmField val BULK_BPS = ModelType(JsonField.of("bulk_bps")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - BPS, + BULK_BPS, } enum class Value { - BPS, + BULK_BPS, _UNKNOWN, } fun value(): Value = when (this) { - BPS -> Value.BPS + BULK_BPS -> Value.BULK_BPS else -> Value._UNKNOWN } fun known(): Known = when (this) { - BPS -> Known.BPS + BULK_BPS -> Known.BULK_BPS else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -11887,25 +13848,25 @@ private constructor( return true } - return /* spotless:off */ other is BpsPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.bpsConfig == other.bpsConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBpsPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.bulkBpsConfig == other.bulkBpsConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, bpsConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, bulkBpsConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "BpsPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, bpsConfig=$bpsConfig, additionalProperties=$additionalProperties}" + "BulkBpsPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, bulkBpsConfig=$bulkBpsConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = BulkBpsPrice.Builder::class) + @JsonDeserialize(builder = BulkPrice.Builder::class) @NoAutoDetect - class BulkBpsPrice + class BulkPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -11929,7 +13890,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val bulkBpsConfig: JsonField, + private val bulkConfig: JsonField, private val additionalProperties: Map, ) { @@ -11996,7 +13957,7 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -12055,13 +14016,13 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("bulk_bps_config") @ExcludeMissing fun _bulkBpsConfig() = bulkBpsConfig + @JsonProperty("bulk_config") @ExcludeMissing fun _bulkConfig() = bulkConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): BulkBpsPrice = apply { + fun validate(): BulkPrice = apply { if (!validated) { metadata().validate() id() @@ -12085,7 +14046,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - bulkBpsConfig().validate() + bulkConfig().validate() validated = true } } @@ -12123,35 +14084,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var bulkBpsConfig: JsonField = JsonMissing.of() + private var bulkConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkBpsPrice: BulkBpsPrice) = apply { - this.metadata = bulkBpsPrice.metadata - this.id = bulkBpsPrice.id - this.name = bulkBpsPrice.name - this.externalPriceId = bulkBpsPrice.externalPriceId - this.priceType = bulkBpsPrice.priceType - this.modelType = bulkBpsPrice.modelType - this.createdAt = bulkBpsPrice.createdAt - this.cadence = bulkBpsPrice.cadence - this.billingCycleConfiguration = bulkBpsPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = bulkBpsPrice.invoicingCycleConfiguration - this.billableMetric = bulkBpsPrice.billableMetric - this.fixedPriceQuantity = bulkBpsPrice.fixedPriceQuantity - this.planPhaseOrder = bulkBpsPrice.planPhaseOrder - this.currency = bulkBpsPrice.currency - this.conversionRate = bulkBpsPrice.conversionRate - this.item = bulkBpsPrice.item - this.creditAllocation = bulkBpsPrice.creditAllocation - this.discount = bulkBpsPrice.discount - this.minimum = bulkBpsPrice.minimum - this.minimumAmount = bulkBpsPrice.minimumAmount - this.maximum = bulkBpsPrice.maximum - this.maximumAmount = bulkBpsPrice.maximumAmount - this.bulkBpsConfig = bulkBpsPrice.bulkBpsConfig - additionalProperties(bulkBpsPrice.additionalProperties) + internal fun from(bulkPrice: BulkPrice) = apply { + this.metadata = bulkPrice.metadata + this.id = bulkPrice.id + this.name = bulkPrice.name + this.externalPriceId = bulkPrice.externalPriceId + this.priceType = bulkPrice.priceType + this.modelType = bulkPrice.modelType + this.createdAt = bulkPrice.createdAt + this.cadence = bulkPrice.cadence + this.billingCycleConfiguration = bulkPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = bulkPrice.invoicingCycleConfiguration + this.billableMetric = bulkPrice.billableMetric + this.fixedPriceQuantity = bulkPrice.fixedPriceQuantity + this.planPhaseOrder = bulkPrice.planPhaseOrder + this.currency = bulkPrice.currency + this.conversionRate = bulkPrice.conversionRate + this.item = bulkPrice.item + this.creditAllocation = bulkPrice.creditAllocation + this.discount = bulkPrice.discount + this.minimum = bulkPrice.minimum + this.minimumAmount = bulkPrice.minimumAmount + this.maximum = bulkPrice.maximum + this.maximumAmount = bulkPrice.maximumAmount + this.bulkConfig = bulkPrice.bulkConfig + additionalProperties(bulkPrice.additionalProperties) } /** @@ -12326,13 +14287,12 @@ private constructor( this.maximumAmount = maximumAmount } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - @JsonProperty("bulk_bps_config") + @JsonProperty("bulk_config") @ExcludeMissing - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig } fun additionalProperties(additionalProperties: Map) = apply { @@ -12349,8 +14309,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BulkBpsPrice = - BulkBpsPrice( + fun build(): BulkPrice = + BulkPrice( metadata, id, name, @@ -12373,7 +14333,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - bulkBpsConfig, + bulkConfig, additionalProperties.toUnmodifiable(), ) } @@ -12634,9 +14594,9 @@ private constructor( "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = BulkBpsConfig.Builder::class) + @JsonDeserialize(builder = BulkConfig.Builder::class) @NoAutoDetect - class BulkBpsConfig + class BulkConfig private constructor( private val tiers: JsonField>, private val additionalProperties: Map, @@ -12644,23 +14604,17 @@ private constructor( private var validated: Boolean = false - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ + /** Bulk tiers for rating based on total usage 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 - */ + /** Bulk tiers for rating based on total usage volume */ @JsonProperty("tiers") @ExcludeMissing fun _tiers() = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): BulkBpsConfig = apply { + fun validate(): BulkConfig = apply { if (!validated) { tiers().forEach { it.validate() } validated = true @@ -12680,21 +14634,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - this.tiers = bulkBpsConfig.tiers - additionalProperties(bulkBpsConfig.additionalProperties) + internal fun from(bulkConfig: BulkConfig) = apply { + this.tiers = bulkConfig.tiers + additionalProperties(bulkConfig.additionalProperties) } - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ + /** Bulk tiers for rating based on total usage 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 - */ + /** Bulk tiers for rating based on total usage volume */ @JsonProperty("tiers") @ExcludeMissing fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } @@ -12714,8 +14662,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BulkBpsConfig = - BulkBpsConfig( + fun build(): BulkConfig = + BulkConfig( tiers.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable() ) @@ -12725,35 +14673,25 @@ private constructor( @NoAutoDetect class Tier private constructor( - private val maximumAmount: JsonField, - private val bps: JsonField, - private val perUnitMaximum: JsonField, + private val maximumUnits: JsonField, + private val unitAmount: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - /** Upper bound for tier */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + /** Amount per unit */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps() = bps + /** Upper bound for this tier */ + @JsonProperty("maximum_units") @ExcludeMissing fun _maximumUnits() = maximumUnits - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum() = perUnitMaximum + /** Amount per unit */ + @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount @JsonAnyGetter @ExcludeMissing @@ -12761,9 +14699,8 @@ private constructor( fun validate(): Tier = apply { if (!validated) { - maximumAmount() - bps() - perUnitMaximum() + maximumUnits() + unitAmount() validated = true } } @@ -12777,47 +14714,36 @@ private constructor( class Builder { - private var maximumAmount: JsonField = JsonMissing.of() - private var bps: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() + private var maximumUnits: JsonField = JsonMissing.of() + private var unitAmount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tier: Tier) = apply { - this.maximumAmount = tier.maximumAmount - this.bps = tier.bps - this.perUnitMaximum = tier.perUnitMaximum + this.maximumUnits = tier.maximumUnits + this.unitAmount = tier.unitAmount additionalProperties(tier.additionalProperties) } - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: Double) = + maximumUnits(JsonField.of(maximumUnits)) - /** Upper bound for tier */ - @JsonProperty("maximum_amount") + /** Upper bound for this tier */ + @JsonProperty("maximum_units") @ExcludeMissing - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits } - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - @JsonProperty("bps") - @ExcludeMissing - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String) = - perUnitMaximum(JsonField.of(perUnitMaximum)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") + /** Amount per unit */ + @JsonProperty("unit_amount") @ExcludeMissing - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = apply { @@ -12837,9 +14763,8 @@ private constructor( fun build(): Tier = Tier( - maximumAmount, - bps, - perUnitMaximum, + maximumUnits, + unitAmount, additionalProperties.toUnmodifiable(), ) } @@ -12849,20 +14774,20 @@ private constructor( return true } - return /* spotless:off */ other is Tier && this.maximumAmount == other.maximumAmount && this.bps == other.bps && this.perUnitMaximum == other.perUnitMaximum && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tier && this.maximumUnits == other.maximumUnits && this.unitAmount == other.unitAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(maximumAmount, bps, perUnitMaximum, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(maximumUnits, unitAmount, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Tier{maximumAmount=$maximumAmount, bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" + "Tier{maximumUnits=$maximumUnits, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -12870,7 +14795,7 @@ private constructor( return true } - return /* spotless:off */ other is BulkBpsConfig && this.tiers == other.tiers && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkConfig && this.tiers == other.tiers && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -12883,7 +14808,7 @@ private constructor( } override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "BulkConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } class Cadence @@ -13724,29 +15649,29 @@ private constructor( companion object { - @JvmField val BULK_BPS = ModelType(JsonField.of("bulk_bps")) + @JvmField val BULK = ModelType(JsonField.of("bulk")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - BULK_BPS, + BULK, } enum class Value { - BULK_BPS, + BULK, _UNKNOWN, } fun value(): Value = when (this) { - BULK_BPS -> Value.BULK_BPS + BULK -> Value.BULK else -> Value._UNKNOWN } fun known(): Known = when (this) { - BULK_BPS -> Known.BULK_BPS + BULK -> Known.BULK else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -13815,25 +15740,25 @@ private constructor( return true } - return /* spotless:off */ other is BulkBpsPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.bulkBpsConfig == other.bulkBpsConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.bulkConfig == other.bulkConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, bulkBpsConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, bulkConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "BulkBpsPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, bulkBpsConfig=$bulkBpsConfig, additionalProperties=$additionalProperties}" + "BulkPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, bulkConfig=$bulkConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = BulkPrice.Builder::class) + @JsonDeserialize(builder = ThresholdTotalAmountPrice.Builder::class) @NoAutoDetect - class BulkPrice + class ThresholdTotalAmountPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -13857,7 +15782,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val bulkConfig: JsonField, + private val thresholdTotalAmountConfig: JsonField, private val additionalProperties: Map, ) { @@ -13924,7 +15849,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -13983,13 +15909,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("bulk_config") @ExcludeMissing fun _bulkConfig() = bulkConfig + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig() = thresholdTotalAmountConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): BulkPrice = apply { + fun validate(): ThresholdTotalAmountPrice = apply { if (!validated) { metadata().validate() id() @@ -14013,7 +15941,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - bulkConfig().validate() + thresholdTotalAmountConfig().validate() validated = true } } @@ -14051,35 +15979,38 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var bulkConfig: JsonField = JsonMissing.of() + private var thresholdTotalAmountConfig: JsonField = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkPrice: BulkPrice) = apply { - this.metadata = bulkPrice.metadata - this.id = bulkPrice.id - this.name = bulkPrice.name - this.externalPriceId = bulkPrice.externalPriceId - this.priceType = bulkPrice.priceType - this.modelType = bulkPrice.modelType - this.createdAt = bulkPrice.createdAt - this.cadence = bulkPrice.cadence - this.billingCycleConfiguration = bulkPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = bulkPrice.invoicingCycleConfiguration - this.billableMetric = bulkPrice.billableMetric - this.fixedPriceQuantity = bulkPrice.fixedPriceQuantity - this.planPhaseOrder = bulkPrice.planPhaseOrder - this.currency = bulkPrice.currency - this.conversionRate = bulkPrice.conversionRate - this.item = bulkPrice.item - this.creditAllocation = bulkPrice.creditAllocation - this.discount = bulkPrice.discount - this.minimum = bulkPrice.minimum - this.minimumAmount = bulkPrice.minimumAmount - this.maximum = bulkPrice.maximum - this.maximumAmount = bulkPrice.maximumAmount - this.bulkConfig = bulkPrice.bulkConfig - additionalProperties(bulkPrice.additionalProperties) + internal fun from(thresholdTotalAmountPrice: ThresholdTotalAmountPrice) = apply { + this.metadata = thresholdTotalAmountPrice.metadata + this.id = thresholdTotalAmountPrice.id + this.name = thresholdTotalAmountPrice.name + this.externalPriceId = thresholdTotalAmountPrice.externalPriceId + this.priceType = thresholdTotalAmountPrice.priceType + this.modelType = thresholdTotalAmountPrice.modelType + this.createdAt = thresholdTotalAmountPrice.createdAt + this.cadence = thresholdTotalAmountPrice.cadence + this.billingCycleConfiguration = thresholdTotalAmountPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + thresholdTotalAmountPrice.invoicingCycleConfiguration + this.billableMetric = thresholdTotalAmountPrice.billableMetric + this.fixedPriceQuantity = thresholdTotalAmountPrice.fixedPriceQuantity + this.planPhaseOrder = thresholdTotalAmountPrice.planPhaseOrder + this.currency = thresholdTotalAmountPrice.currency + this.conversionRate = thresholdTotalAmountPrice.conversionRate + this.item = thresholdTotalAmountPrice.item + this.creditAllocation = thresholdTotalAmountPrice.creditAllocation + this.discount = thresholdTotalAmountPrice.discount + this.minimum = thresholdTotalAmountPrice.minimum + this.minimumAmount = thresholdTotalAmountPrice.minimumAmount + this.maximum = thresholdTotalAmountPrice.maximum + this.maximumAmount = thresholdTotalAmountPrice.maximumAmount + this.thresholdTotalAmountConfig = + thresholdTotalAmountPrice.thresholdTotalAmountConfig + additionalProperties(thresholdTotalAmountPrice.additionalProperties) } /** @@ -14254,13 +16185,14 @@ private constructor( this.maximumAmount = maximumAmount } - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = + thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - @JsonProperty("bulk_config") + @JsonProperty("threshold_total_amount_config") @ExcludeMissing - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -14276,8 +16208,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BulkPrice = - BulkPrice( + fun build(): ThresholdTotalAmountPrice = + ThresholdTotalAmountPrice( metadata, id, name, @@ -14300,7 +16232,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - bulkConfig, + thresholdTotalAmountConfig, additionalProperties.toUnmodifiable(), ) } @@ -14561,223 +16493,6 @@ private constructor( "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = BulkConfig.Builder::class) - @NoAutoDetect - class BulkConfig - private constructor( - private val tiers: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** 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() = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): BulkConfig = apply { - if (!validated) { - tiers().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var tiers: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - this.tiers = bulkConfig.tiers - additionalProperties(bulkConfig.additionalProperties) - } - - /** 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 */ - @JsonProperty("tiers") - @ExcludeMissing - fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): BulkConfig = - BulkConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } - - @JsonDeserialize(builder = Tier.Builder::class) - @NoAutoDetect - class Tier - private constructor( - private val maximumUnits: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") @ExcludeMissing fun _maximumUnits() = maximumUnits - - /** Amount per unit */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Tier = apply { - if (!validated) { - maximumUnits() - unitAmount() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var maximumUnits: JsonField = JsonMissing.of() - private var unitAmount: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - this.maximumUnits = tier.maximumUnits - this.unitAmount = tier.unitAmount - additionalProperties(tier.additionalProperties) - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(JsonField.of(maximumUnits)) - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Tier = - Tier( - maximumUnits, - unitAmount, - additionalProperties.toUnmodifiable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && this.maximumUnits == other.maximumUnits && this.unitAmount == other.unitAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(maximumUnits, unitAmount, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Tier{maximumUnits=$maximumUnits, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && this.tiers == other.tiers && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(tiers, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "BulkConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - class Cadence @JsonCreator private constructor( @@ -15616,29 +17331,30 @@ private constructor( companion object { - @JvmField val BULK = ModelType(JsonField.of("bulk")) + @JvmField + val THRESHOLD_TOTAL_AMOUNT = ModelType(JsonField.of("threshold_total_amount")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - BULK, + THRESHOLD_TOTAL_AMOUNT, } enum class Value { - BULK, + THRESHOLD_TOTAL_AMOUNT, _UNKNOWN, } fun value(): Value = when (this) { - BULK -> Value.BULK + THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT else -> Value._UNKNOWN } fun known(): Known = when (this) { - BULK -> Known.BULK + THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -15702,30 +17418,105 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + @JsonDeserialize(builder = ThresholdTotalAmountConfig.Builder::class) + @NoAutoDetect + class ThresholdTotalAmountConfig + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ThresholdTotalAmountConfig = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { + additionalProperties(thresholdTotalAmountConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ThresholdTotalAmountConfig = + ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ThresholdTotalAmountConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BulkPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.bulkConfig == other.bulkConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmountPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, bulkConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, thresholdTotalAmountConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "BulkPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, bulkConfig=$bulkConfig, additionalProperties=$additionalProperties}" + "ThresholdTotalAmountPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = ThresholdTotalAmountPrice.Builder::class) + @JsonDeserialize(builder = TieredPackagePrice.Builder::class) @NoAutoDetect - class ThresholdTotalAmountPrice + class TieredPackagePrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -15749,7 +17540,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val thresholdTotalAmountConfig: JsonField, + private val tieredPackageConfig: JsonField, private val additionalProperties: Map, ) { @@ -15816,8 +17607,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -15876,15 +17667,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("threshold_total_amount_config") + @JsonProperty("tiered_package_config") @ExcludeMissing - fun _thresholdTotalAmountConfig() = thresholdTotalAmountConfig + fun _tieredPackageConfig() = tieredPackageConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): ThresholdTotalAmountPrice = apply { + fun validate(): TieredPackagePrice = apply { if (!validated) { metadata().validate() id() @@ -15908,7 +17699,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - thresholdTotalAmountConfig().validate() + tieredPackageConfig().validate() validated = true } } @@ -15946,38 +17737,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var thresholdTotalAmountConfig: JsonField = - JsonMissing.of() + private var tieredPackageConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(thresholdTotalAmountPrice: ThresholdTotalAmountPrice) = apply { - this.metadata = thresholdTotalAmountPrice.metadata - this.id = thresholdTotalAmountPrice.id - this.name = thresholdTotalAmountPrice.name - this.externalPriceId = thresholdTotalAmountPrice.externalPriceId - this.priceType = thresholdTotalAmountPrice.priceType - this.modelType = thresholdTotalAmountPrice.modelType - this.createdAt = thresholdTotalAmountPrice.createdAt - this.cadence = thresholdTotalAmountPrice.cadence - this.billingCycleConfiguration = thresholdTotalAmountPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = - thresholdTotalAmountPrice.invoicingCycleConfiguration - this.billableMetric = thresholdTotalAmountPrice.billableMetric - this.fixedPriceQuantity = thresholdTotalAmountPrice.fixedPriceQuantity - this.planPhaseOrder = thresholdTotalAmountPrice.planPhaseOrder - this.currency = thresholdTotalAmountPrice.currency - this.conversionRate = thresholdTotalAmountPrice.conversionRate - this.item = thresholdTotalAmountPrice.item - this.creditAllocation = thresholdTotalAmountPrice.creditAllocation - this.discount = thresholdTotalAmountPrice.discount - this.minimum = thresholdTotalAmountPrice.minimum - this.minimumAmount = thresholdTotalAmountPrice.minimumAmount - this.maximum = thresholdTotalAmountPrice.maximum - this.maximumAmount = thresholdTotalAmountPrice.maximumAmount - this.thresholdTotalAmountConfig = - thresholdTotalAmountPrice.thresholdTotalAmountConfig - additionalProperties(thresholdTotalAmountPrice.additionalProperties) + internal fun from(tieredPackagePrice: TieredPackagePrice) = apply { + this.metadata = tieredPackagePrice.metadata + this.id = tieredPackagePrice.id + this.name = tieredPackagePrice.name + this.externalPriceId = tieredPackagePrice.externalPriceId + this.priceType = tieredPackagePrice.priceType + this.modelType = tieredPackagePrice.modelType + this.createdAt = tieredPackagePrice.createdAt + this.cadence = tieredPackagePrice.cadence + this.billingCycleConfiguration = tieredPackagePrice.billingCycleConfiguration + this.invoicingCycleConfiguration = tieredPackagePrice.invoicingCycleConfiguration + this.billableMetric = tieredPackagePrice.billableMetric + this.fixedPriceQuantity = tieredPackagePrice.fixedPriceQuantity + this.planPhaseOrder = tieredPackagePrice.planPhaseOrder + this.currency = tieredPackagePrice.currency + this.conversionRate = tieredPackagePrice.conversionRate + this.item = tieredPackagePrice.item + this.creditAllocation = tieredPackagePrice.creditAllocation + this.discount = tieredPackagePrice.discount + this.minimum = tieredPackagePrice.minimum + this.minimumAmount = tieredPackagePrice.minimumAmount + this.maximum = tieredPackagePrice.maximum + this.maximumAmount = tieredPackagePrice.maximumAmount + this.tieredPackageConfig = tieredPackagePrice.tieredPackageConfig + additionalProperties(tieredPackagePrice.additionalProperties) } /** @@ -16152,14 +17940,14 @@ private constructor( this.maximumAmount = maximumAmount } - fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) - @JsonProperty("threshold_total_amount_config") + @JsonProperty("tiered_package_config") @ExcludeMissing - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + fun tieredPackageConfig(tieredPackageConfig: JsonField) = apply { + this.tieredPackageConfig = tieredPackageConfig + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -16175,8 +17963,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ThresholdTotalAmountPrice = - ThresholdTotalAmountPrice( + fun build(): TieredPackagePrice = + TieredPackagePrice( metadata, id, name, @@ -16199,7 +17987,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - thresholdTotalAmountConfig, + tieredPackageConfig, additionalProperties.toUnmodifiable(), ) } @@ -17298,30 +19086,29 @@ private constructor( companion object { - @JvmField - val THRESHOLD_TOTAL_AMOUNT = ModelType(JsonField.of("threshold_total_amount")) + @JvmField val TIERED_PACKAGE = ModelType(JsonField.of("tiered_package")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - THRESHOLD_TOTAL_AMOUNT, + TIERED_PACKAGE, } enum class Value { - THRESHOLD_TOTAL_AMOUNT, + TIERED_PACKAGE, _UNKNOWN, } fun value(): Value = when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT + TIERED_PACKAGE -> Value.TIERED_PACKAGE else -> Value._UNKNOWN } fun known(): Known = when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT + TIERED_PACKAGE -> Known.TIERED_PACKAGE else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -17385,9 +19172,9 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = ThresholdTotalAmountConfig.Builder::class) + @JsonDeserialize(builder = TieredPackageConfig.Builder::class) @NoAutoDetect - class ThresholdTotalAmountConfig + class TieredPackageConfig private constructor( private val additionalProperties: Map, ) { @@ -17398,7 +19185,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): ThresholdTotalAmountConfig = apply { + fun validate(): TieredPackageConfig = apply { if (!validated) { validated = true } @@ -17416,8 +19203,8 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { - additionalProperties(thresholdTotalAmountConfig.additionalProperties) + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + additionalProperties(tieredPackageConfig.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -17435,8 +19222,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + fun build(): TieredPackageConfig = + TieredPackageConfig(additionalProperties.toUnmodifiable()) } override fun equals(other: Any?): Boolean { @@ -17444,7 +19231,7 @@ private constructor( return true } - return /* spotless:off */ other is ThresholdTotalAmountConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackageConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -17457,7 +19244,7 @@ private constructor( } override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" + "TieredPackageConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -17465,25 +19252,25 @@ private constructor( return true } - return /* spotless:off */ other is ThresholdTotalAmountPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackagePrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredPackageConfig == other.tieredPackageConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, thresholdTotalAmountConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredPackageConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ThresholdTotalAmountPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, additionalProperties=$additionalProperties}" + "TieredPackagePrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredPackageConfig=$tieredPackageConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = TieredPackagePrice.Builder::class) + @JsonDeserialize(builder = GroupedTieredPrice.Builder::class) @NoAutoDetect - class TieredPackagePrice + class GroupedTieredPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -17507,7 +19294,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val tieredPackageConfig: JsonField, + private val groupedTieredConfig: JsonField, private val additionalProperties: Map, ) { @@ -17574,8 +19361,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -17634,15 +19421,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("tiered_package_config") + @JsonProperty("grouped_tiered_config") @ExcludeMissing - fun _tieredPackageConfig() = tieredPackageConfig + fun _groupedTieredConfig() = groupedTieredConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredPackagePrice = apply { + fun validate(): GroupedTieredPrice = apply { if (!validated) { metadata().validate() id() @@ -17666,7 +19453,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - tieredPackageConfig().validate() + groupedTieredConfig().validate() validated = true } } @@ -17704,35 +19491,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var tieredPackageConfig: JsonField = JsonMissing.of() + private var groupedTieredConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackagePrice: TieredPackagePrice) = apply { - this.metadata = tieredPackagePrice.metadata - this.id = tieredPackagePrice.id - this.name = tieredPackagePrice.name - this.externalPriceId = tieredPackagePrice.externalPriceId - this.priceType = tieredPackagePrice.priceType - this.modelType = tieredPackagePrice.modelType - this.createdAt = tieredPackagePrice.createdAt - this.cadence = tieredPackagePrice.cadence - this.billingCycleConfiguration = tieredPackagePrice.billingCycleConfiguration - this.invoicingCycleConfiguration = tieredPackagePrice.invoicingCycleConfiguration - this.billableMetric = tieredPackagePrice.billableMetric - this.fixedPriceQuantity = tieredPackagePrice.fixedPriceQuantity - this.planPhaseOrder = tieredPackagePrice.planPhaseOrder - this.currency = tieredPackagePrice.currency - this.conversionRate = tieredPackagePrice.conversionRate - this.item = tieredPackagePrice.item - this.creditAllocation = tieredPackagePrice.creditAllocation - this.discount = tieredPackagePrice.discount - this.minimum = tieredPackagePrice.minimum - this.minimumAmount = tieredPackagePrice.minimumAmount - this.maximum = tieredPackagePrice.maximum - this.maximumAmount = tieredPackagePrice.maximumAmount - this.tieredPackageConfig = tieredPackagePrice.tieredPackageConfig - additionalProperties(tieredPackagePrice.additionalProperties) + internal fun from(groupedTieredPrice: GroupedTieredPrice) = apply { + this.metadata = groupedTieredPrice.metadata + this.id = groupedTieredPrice.id + this.name = groupedTieredPrice.name + this.externalPriceId = groupedTieredPrice.externalPriceId + this.priceType = groupedTieredPrice.priceType + this.modelType = groupedTieredPrice.modelType + this.createdAt = groupedTieredPrice.createdAt + this.cadence = groupedTieredPrice.cadence + this.billingCycleConfiguration = groupedTieredPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = groupedTieredPrice.invoicingCycleConfiguration + this.billableMetric = groupedTieredPrice.billableMetric + this.fixedPriceQuantity = groupedTieredPrice.fixedPriceQuantity + this.planPhaseOrder = groupedTieredPrice.planPhaseOrder + this.currency = groupedTieredPrice.currency + this.conversionRate = groupedTieredPrice.conversionRate + this.item = groupedTieredPrice.item + this.creditAllocation = groupedTieredPrice.creditAllocation + this.discount = groupedTieredPrice.discount + this.minimum = groupedTieredPrice.minimum + this.minimumAmount = groupedTieredPrice.minimumAmount + this.maximum = groupedTieredPrice.maximum + this.maximumAmount = groupedTieredPrice.maximumAmount + this.groupedTieredConfig = groupedTieredPrice.groupedTieredConfig + additionalProperties(groupedTieredPrice.additionalProperties) } /** @@ -17907,13 +19694,13 @@ private constructor( this.maximumAmount = maximumAmount } - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) - @JsonProperty("tiered_package_config") + @JsonProperty("grouped_tiered_config") @ExcludeMissing - fun tieredPackageConfig(tieredPackageConfig: JsonField) = apply { - this.tieredPackageConfig = tieredPackageConfig + fun groupedTieredConfig(groupedTieredConfig: JsonField) = apply { + this.groupedTieredConfig = groupedTieredConfig } fun additionalProperties(additionalProperties: Map) = apply { @@ -17930,8 +19717,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredPackagePrice = - TieredPackagePrice( + fun build(): GroupedTieredPrice = + GroupedTieredPrice( metadata, id, name, @@ -17954,7 +19741,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - tieredPackageConfig, + groupedTieredConfig, additionalProperties.toUnmodifiable(), ) } @@ -18406,6 +20193,81 @@ private constructor( "CreditAllocation{currency=$currency, allowsRollover=$allowsRollover, additionalProperties=$additionalProperties}" } + @JsonDeserialize(builder = GroupedTieredConfig.Builder::class) + @NoAutoDetect + class GroupedTieredConfig + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): GroupedTieredConfig = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { + additionalProperties(groupedTieredConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): GroupedTieredConfig = + GroupedTieredConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupedTieredConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GroupedTieredConfig{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) @NoAutoDetect class InvoicingCycleConfiguration @@ -19053,29 +20915,29 @@ private constructor( companion object { - @JvmField val TIERED_PACKAGE = ModelType(JsonField.of("tiered_package")) + @JvmField val GROUPED_TIERED = ModelType(JsonField.of("grouped_tiered")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - TIERED_PACKAGE, + GROUPED_TIERED, } enum class Value { - TIERED_PACKAGE, + GROUPED_TIERED, _UNKNOWN, } fun value(): Value = when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE + GROUPED_TIERED -> Value.GROUPED_TIERED else -> Value._UNKNOWN } fun known(): Known = when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE + GROUPED_TIERED -> Known.GROUPED_TIERED else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -19139,105 +21001,30 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = TieredPackageConfig.Builder::class) - @NoAutoDetect - class TieredPackageConfig - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TieredPackageConfig = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties(tieredPackageConfig.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is TieredPackagePrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredPackageConfig == other.tieredPackageConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.groupedTieredConfig == other.groupedTieredConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredPackageConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, groupedTieredConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "TieredPackagePrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredPackageConfig=$tieredPackageConfig, additionalProperties=$additionalProperties}" + "GroupedTieredPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, groupedTieredConfig=$groupedTieredConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GroupedTieredPrice.Builder::class) + @JsonDeserialize(builder = TieredWithMinimumPrice.Builder::class) @NoAutoDetect - class GroupedTieredPrice + class TieredWithMinimumPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -19261,7 +21048,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val groupedTieredConfig: JsonField, + private val tieredWithMinimumConfig: JsonField, private val additionalProperties: Map, ) { @@ -19328,8 +21115,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun groupedTieredConfig(): GroupedTieredConfig = - groupedTieredConfig.getRequired("grouped_tiered_config") + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -19388,15 +21175,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("grouped_tiered_config") + @JsonProperty("tiered_with_minimum_config") @ExcludeMissing - fun _groupedTieredConfig() = groupedTieredConfig + fun _tieredWithMinimumConfig() = tieredWithMinimumConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): GroupedTieredPrice = apply { + fun validate(): TieredWithMinimumPrice = apply { if (!validated) { metadata().validate() id() @@ -19420,7 +21207,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - groupedTieredConfig().validate() + tieredWithMinimumConfig().validate() validated = true } } @@ -19458,35 +21245,37 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var groupedTieredConfig: JsonField = JsonMissing.of() + private var tieredWithMinimumConfig: JsonField = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedTieredPrice: GroupedTieredPrice) = apply { - this.metadata = groupedTieredPrice.metadata - this.id = groupedTieredPrice.id - this.name = groupedTieredPrice.name - this.externalPriceId = groupedTieredPrice.externalPriceId - this.priceType = groupedTieredPrice.priceType - this.modelType = groupedTieredPrice.modelType - this.createdAt = groupedTieredPrice.createdAt - this.cadence = groupedTieredPrice.cadence - this.billingCycleConfiguration = groupedTieredPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = groupedTieredPrice.invoicingCycleConfiguration - this.billableMetric = groupedTieredPrice.billableMetric - this.fixedPriceQuantity = groupedTieredPrice.fixedPriceQuantity - this.planPhaseOrder = groupedTieredPrice.planPhaseOrder - this.currency = groupedTieredPrice.currency - this.conversionRate = groupedTieredPrice.conversionRate - this.item = groupedTieredPrice.item - this.creditAllocation = groupedTieredPrice.creditAllocation - this.discount = groupedTieredPrice.discount - this.minimum = groupedTieredPrice.minimum - this.minimumAmount = groupedTieredPrice.minimumAmount - this.maximum = groupedTieredPrice.maximum - this.maximumAmount = groupedTieredPrice.maximumAmount - this.groupedTieredConfig = groupedTieredPrice.groupedTieredConfig - additionalProperties(groupedTieredPrice.additionalProperties) + internal fun from(tieredWithMinimumPrice: TieredWithMinimumPrice) = apply { + this.metadata = tieredWithMinimumPrice.metadata + this.id = tieredWithMinimumPrice.id + this.name = tieredWithMinimumPrice.name + this.externalPriceId = tieredWithMinimumPrice.externalPriceId + this.priceType = tieredWithMinimumPrice.priceType + this.modelType = tieredWithMinimumPrice.modelType + this.createdAt = tieredWithMinimumPrice.createdAt + this.cadence = tieredWithMinimumPrice.cadence + this.billingCycleConfiguration = tieredWithMinimumPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + tieredWithMinimumPrice.invoicingCycleConfiguration + this.billableMetric = tieredWithMinimumPrice.billableMetric + this.fixedPriceQuantity = tieredWithMinimumPrice.fixedPriceQuantity + this.planPhaseOrder = tieredWithMinimumPrice.planPhaseOrder + this.currency = tieredWithMinimumPrice.currency + this.conversionRate = tieredWithMinimumPrice.conversionRate + this.item = tieredWithMinimumPrice.item + this.creditAllocation = tieredWithMinimumPrice.creditAllocation + this.discount = tieredWithMinimumPrice.discount + this.minimum = tieredWithMinimumPrice.minimum + this.minimumAmount = tieredWithMinimumPrice.minimumAmount + this.maximum = tieredWithMinimumPrice.maximum + this.maximumAmount = tieredWithMinimumPrice.maximumAmount + this.tieredWithMinimumConfig = tieredWithMinimumPrice.tieredWithMinimumConfig + additionalProperties(tieredWithMinimumPrice.additionalProperties) } /** @@ -19661,14 +21450,14 @@ private constructor( this.maximumAmount = maximumAmount } - fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = - groupedTieredConfig(JsonField.of(groupedTieredConfig)) + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - @JsonProperty("grouped_tiered_config") + @JsonProperty("tiered_with_minimum_config") @ExcludeMissing - fun groupedTieredConfig(groupedTieredConfig: JsonField) = apply { - this.groupedTieredConfig = groupedTieredConfig - } + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -19684,8 +21473,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupedTieredPrice = - GroupedTieredPrice( + fun build(): TieredWithMinimumPrice = + TieredWithMinimumPrice( metadata, id, name, @@ -19708,7 +21497,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - groupedTieredConfig, + tieredWithMinimumConfig, additionalProperties.toUnmodifiable(), ) } @@ -20160,81 +21949,6 @@ private constructor( "CreditAllocation{currency=$currency, allowsRollover=$allowsRollover, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GroupedTieredConfig.Builder::class) - @NoAutoDetect - class GroupedTieredConfig - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GroupedTieredConfig = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { - additionalProperties(groupedTieredConfig.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toUnmodifiable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedTieredConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "GroupedTieredConfig{additionalProperties=$additionalProperties}" - } - @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) @NoAutoDetect class InvoicingCycleConfiguration @@ -20882,29 +22596,29 @@ private constructor( companion object { - @JvmField val GROUPED_TIERED = ModelType(JsonField.of("grouped_tiered")) + @JvmField val TIERED_WITH_MINIMUM = ModelType(JsonField.of("tiered_with_minimum")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - GROUPED_TIERED, + TIERED_WITH_MINIMUM, } enum class Value { - GROUPED_TIERED, + TIERED_WITH_MINIMUM, _UNKNOWN, } fun value(): Value = when (this) { - GROUPED_TIERED -> Value.GROUPED_TIERED + TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM else -> Value._UNKNOWN } fun known(): Known = when (this) { - GROUPED_TIERED -> Known.GROUPED_TIERED + TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -20968,30 +22682,105 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + @JsonDeserialize(builder = TieredWithMinimumConfig.Builder::class) + @NoAutoDetect + class TieredWithMinimumConfig + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TieredWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { + additionalProperties(tieredWithMinimumConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TieredWithMinimumConfig = + TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredWithMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedTieredPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.groupedTieredConfig == other.groupedTieredConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimumPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredWithMinimumConfig == other.tieredWithMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, groupedTieredConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredWithMinimumConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "GroupedTieredPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, groupedTieredConfig=$groupedTieredConfig, additionalProperties=$additionalProperties}" + "TieredWithMinimumPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredWithMinimumConfig=$tieredWithMinimumConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = TieredWithMinimumPrice.Builder::class) + @JsonDeserialize(builder = TieredPackageWithMinimumPrice.Builder::class) @NoAutoDetect - class TieredWithMinimumPrice + class TieredPackageWithMinimumPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -21015,7 +22804,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val tieredWithMinimumConfig: JsonField, + private val tieredPackageWithMinimumConfig: JsonField, private val additionalProperties: Map, ) { @@ -21082,8 +22871,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -21142,15 +22931,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("tiered_with_minimum_config") + @JsonProperty("tiered_package_with_minimum_config") @ExcludeMissing - fun _tieredWithMinimumConfig() = tieredWithMinimumConfig + fun _tieredPackageWithMinimumConfig() = tieredPackageWithMinimumConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredWithMinimumPrice = apply { + fun validate(): TieredPackageWithMinimumPrice = apply { if (!validated) { metadata().validate() id() @@ -21174,7 +22963,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - tieredWithMinimumConfig().validate() + tieredPackageWithMinimumConfig().validate() validated = true } } @@ -21212,38 +23001,41 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var tieredWithMinimumConfig: JsonField = + private var tieredPackageWithMinimumConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithMinimumPrice: TieredWithMinimumPrice) = apply { - this.metadata = tieredWithMinimumPrice.metadata - this.id = tieredWithMinimumPrice.id - this.name = tieredWithMinimumPrice.name - this.externalPriceId = tieredWithMinimumPrice.externalPriceId - this.priceType = tieredWithMinimumPrice.priceType - this.modelType = tieredWithMinimumPrice.modelType - this.createdAt = tieredWithMinimumPrice.createdAt - this.cadence = tieredWithMinimumPrice.cadence - this.billingCycleConfiguration = tieredWithMinimumPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = - tieredWithMinimumPrice.invoicingCycleConfiguration - this.billableMetric = tieredWithMinimumPrice.billableMetric - this.fixedPriceQuantity = tieredWithMinimumPrice.fixedPriceQuantity - this.planPhaseOrder = tieredWithMinimumPrice.planPhaseOrder - this.currency = tieredWithMinimumPrice.currency - this.conversionRate = tieredWithMinimumPrice.conversionRate - this.item = tieredWithMinimumPrice.item - this.creditAllocation = tieredWithMinimumPrice.creditAllocation - this.discount = tieredWithMinimumPrice.discount - this.minimum = tieredWithMinimumPrice.minimum - this.minimumAmount = tieredWithMinimumPrice.minimumAmount - this.maximum = tieredWithMinimumPrice.maximum - this.maximumAmount = tieredWithMinimumPrice.maximumAmount - this.tieredWithMinimumConfig = tieredWithMinimumPrice.tieredWithMinimumConfig - additionalProperties(tieredWithMinimumPrice.additionalProperties) - } + internal fun from(tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice) = + apply { + this.metadata = tieredPackageWithMinimumPrice.metadata + this.id = tieredPackageWithMinimumPrice.id + this.name = tieredPackageWithMinimumPrice.name + this.externalPriceId = tieredPackageWithMinimumPrice.externalPriceId + this.priceType = tieredPackageWithMinimumPrice.priceType + this.modelType = tieredPackageWithMinimumPrice.modelType + this.createdAt = tieredPackageWithMinimumPrice.createdAt + this.cadence = tieredPackageWithMinimumPrice.cadence + this.billingCycleConfiguration = + tieredPackageWithMinimumPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + tieredPackageWithMinimumPrice.invoicingCycleConfiguration + this.billableMetric = tieredPackageWithMinimumPrice.billableMetric + this.fixedPriceQuantity = tieredPackageWithMinimumPrice.fixedPriceQuantity + this.planPhaseOrder = tieredPackageWithMinimumPrice.planPhaseOrder + this.currency = tieredPackageWithMinimumPrice.currency + this.conversionRate = tieredPackageWithMinimumPrice.conversionRate + this.item = tieredPackageWithMinimumPrice.item + this.creditAllocation = tieredPackageWithMinimumPrice.creditAllocation + this.discount = tieredPackageWithMinimumPrice.discount + this.minimum = tieredPackageWithMinimumPrice.minimum + this.minimumAmount = tieredPackageWithMinimumPrice.minimumAmount + this.maximum = tieredPackageWithMinimumPrice.maximum + this.maximumAmount = tieredPackageWithMinimumPrice.maximumAmount + this.tieredPackageWithMinimumConfig = + tieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig + additionalProperties(tieredPackageWithMinimumPrice.additionalProperties) + } /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -21417,14 +23209,15 @@ private constructor( this.maximumAmount = maximumAmount } - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) - @JsonProperty("tiered_with_minimum_config") + @JsonProperty("tiered_package_with_minimum_config") @ExcludeMissing - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -21440,8 +23233,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredWithMinimumPrice = - TieredWithMinimumPrice( + fun build(): TieredPackageWithMinimumPrice = + TieredPackageWithMinimumPrice( metadata, id, name, @@ -21464,7 +23257,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - tieredWithMinimumConfig, + tieredPackageWithMinimumConfig, additionalProperties.toUnmodifiable(), ) } @@ -22563,29 +24356,31 @@ private constructor( companion object { - @JvmField val TIERED_WITH_MINIMUM = ModelType(JsonField.of("tiered_with_minimum")) + @JvmField + val TIERED_PACKAGE_WITH_MINIMUM = + ModelType(JsonField.of("tiered_package_with_minimum")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - TIERED_WITH_MINIMUM, + TIERED_PACKAGE_WITH_MINIMUM, } enum class Value { - TIERED_WITH_MINIMUM, + TIERED_PACKAGE_WITH_MINIMUM, _UNKNOWN, } fun value(): Value = when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM + TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM else -> Value._UNKNOWN } fun known(): Known = when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM + TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -22649,9 +24444,9 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = TieredWithMinimumConfig.Builder::class) + @JsonDeserialize(builder = TieredPackageWithMinimumConfig.Builder::class) @NoAutoDetect - class TieredWithMinimumConfig + class TieredPackageWithMinimumConfig private constructor( private val additionalProperties: Map, ) { @@ -22662,7 +24457,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredWithMinimumConfig = apply { + fun validate(): TieredPackageWithMinimumConfig = apply { if (!validated) { validated = true } @@ -22680,9 +24475,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { - additionalProperties(tieredWithMinimumConfig.additionalProperties) - } + internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = + apply { + additionalProperties(tieredPackageWithMinimumConfig.additionalProperties) + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -22699,8 +24495,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + fun build(): TieredPackageWithMinimumConfig = + TieredPackageWithMinimumConfig(additionalProperties.toUnmodifiable()) } override fun equals(other: Any?): Boolean { @@ -22708,7 +24504,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackageWithMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -22721,7 +24517,7 @@ private constructor( } override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -22729,25 +24525,25 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithMinimumPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredWithMinimumConfig == other.tieredWithMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackageWithMinimumPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredWithMinimumConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredPackageWithMinimumConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "TieredWithMinimumPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredWithMinimumConfig=$tieredWithMinimumConfig, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = TieredPackageWithMinimumPrice.Builder::class) + @JsonDeserialize(builder = PackageWithAllocationPrice.Builder::class) @NoAutoDetect - class TieredPackageWithMinimumPrice + class PackageWithAllocationPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -22771,7 +24567,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val tieredPackageWithMinimumConfig: JsonField, + private val packageWithAllocationConfig: JsonField, private val additionalProperties: Map, ) { @@ -22838,8 +24634,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = - tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -22898,15 +24694,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("tiered_package_with_minimum_config") + @JsonProperty("package_with_allocation_config") @ExcludeMissing - fun _tieredPackageWithMinimumConfig() = tieredPackageWithMinimumConfig + fun _packageWithAllocationConfig() = packageWithAllocationConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredPackageWithMinimumPrice = apply { + fun validate(): PackageWithAllocationPrice = apply { if (!validated) { metadata().validate() id() @@ -22930,7 +24726,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - tieredPackageWithMinimumConfig().validate() + packageWithAllocationConfig().validate() validated = true } } @@ -22968,41 +24764,40 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var tieredPackageWithMinimumConfig: JsonField = + private var packageWithAllocationConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice) = - apply { - this.metadata = tieredPackageWithMinimumPrice.metadata - this.id = tieredPackageWithMinimumPrice.id - this.name = tieredPackageWithMinimumPrice.name - this.externalPriceId = tieredPackageWithMinimumPrice.externalPriceId - this.priceType = tieredPackageWithMinimumPrice.priceType - this.modelType = tieredPackageWithMinimumPrice.modelType - this.createdAt = tieredPackageWithMinimumPrice.createdAt - this.cadence = tieredPackageWithMinimumPrice.cadence - this.billingCycleConfiguration = - tieredPackageWithMinimumPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = - tieredPackageWithMinimumPrice.invoicingCycleConfiguration - this.billableMetric = tieredPackageWithMinimumPrice.billableMetric - this.fixedPriceQuantity = tieredPackageWithMinimumPrice.fixedPriceQuantity - this.planPhaseOrder = tieredPackageWithMinimumPrice.planPhaseOrder - this.currency = tieredPackageWithMinimumPrice.currency - this.conversionRate = tieredPackageWithMinimumPrice.conversionRate - this.item = tieredPackageWithMinimumPrice.item - this.creditAllocation = tieredPackageWithMinimumPrice.creditAllocation - this.discount = tieredPackageWithMinimumPrice.discount - this.minimum = tieredPackageWithMinimumPrice.minimum - this.minimumAmount = tieredPackageWithMinimumPrice.minimumAmount - this.maximum = tieredPackageWithMinimumPrice.maximum - this.maximumAmount = tieredPackageWithMinimumPrice.maximumAmount - this.tieredPackageWithMinimumConfig = - tieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig - additionalProperties(tieredPackageWithMinimumPrice.additionalProperties) - } + internal fun from(packageWithAllocationPrice: PackageWithAllocationPrice) = apply { + this.metadata = packageWithAllocationPrice.metadata + this.id = packageWithAllocationPrice.id + this.name = packageWithAllocationPrice.name + this.externalPriceId = packageWithAllocationPrice.externalPriceId + this.priceType = packageWithAllocationPrice.priceType + this.modelType = packageWithAllocationPrice.modelType + this.createdAt = packageWithAllocationPrice.createdAt + this.cadence = packageWithAllocationPrice.cadence + this.billingCycleConfiguration = + packageWithAllocationPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + packageWithAllocationPrice.invoicingCycleConfiguration + this.billableMetric = packageWithAllocationPrice.billableMetric + this.fixedPriceQuantity = packageWithAllocationPrice.fixedPriceQuantity + this.planPhaseOrder = packageWithAllocationPrice.planPhaseOrder + this.currency = packageWithAllocationPrice.currency + this.conversionRate = packageWithAllocationPrice.conversionRate + this.item = packageWithAllocationPrice.item + this.creditAllocation = packageWithAllocationPrice.creditAllocation + this.discount = packageWithAllocationPrice.discount + this.minimum = packageWithAllocationPrice.minimum + this.minimumAmount = packageWithAllocationPrice.minimumAmount + this.maximum = packageWithAllocationPrice.maximum + this.maximumAmount = packageWithAllocationPrice.maximumAmount + this.packageWithAllocationConfig = + packageWithAllocationPrice.packageWithAllocationConfig + additionalProperties(packageWithAllocationPrice.additionalProperties) + } /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -23176,15 +24971,15 @@ private constructor( this.maximumAmount = maximumAmount } - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig - ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + fun packageWithAllocationConfig( + packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - @JsonProperty("tiered_package_with_minimum_config") + @JsonProperty("package_with_allocation_config") @ExcludeMissing - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: JsonField - ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -23200,8 +24995,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredPackageWithMinimumPrice = - TieredPackageWithMinimumPrice( + fun build(): PackageWithAllocationPrice = + PackageWithAllocationPrice( metadata, id, name, @@ -23224,7 +25019,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - tieredPackageWithMinimumConfig, + packageWithAllocationConfig, additionalProperties.toUnmodifiable(), ) } @@ -24324,96 +26119,38 @@ private constructor( companion object { @JvmField - val TIERED_PACKAGE_WITH_MINIMUM = - ModelType(JsonField.of("tiered_package_with_minimum")) + val PACKAGE_WITH_ALLOCATION = ModelType(JsonField.of("package_with_allocation")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - TIERED_PACKAGE_WITH_MINIMUM, + PACKAGE_WITH_ALLOCATION, } enum class Value { - TIERED_PACKAGE_WITH_MINIMUM, + PACKAGE_WITH_ALLOCATION, _UNKNOWN, } fun value(): Value = when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM + PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION else -> Value._UNKNOWN } fun known(): Known = when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM + PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION else -> throw OrbInvalidDataException("Unknown ModelType: $value") } fun asString(): String = _value().asStringOrThrow() } - class PriceType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USAGE_PRICE = PriceType(JsonField.of("usage_price")) - - @JvmField val FIXED_PRICE = PriceType(JsonField.of("fixed_price")) - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = TieredPackageWithMinimumConfig.Builder::class) + @JsonDeserialize(builder = PackageWithAllocationConfig.Builder::class) @NoAutoDetect - class TieredPackageWithMinimumConfig + class PackageWithAllocationConfig private constructor( private val additionalProperties: Map, ) { @@ -24424,7 +26161,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredPackageWithMinimumConfig = apply { + fun validate(): PackageWithAllocationConfig = apply { if (!validated) { validated = true } @@ -24442,9 +26179,9 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = + internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = apply { - additionalProperties(tieredPackageWithMinimumConfig.additionalProperties) + additionalProperties(packageWithAllocationConfig.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -24462,8 +26199,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toUnmodifiable()) + fun build(): PackageWithAllocationConfig = + PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) } override fun equals(other: Any?): Boolean { @@ -24471,7 +26208,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageWithMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -24484,7 +26221,64 @@ private constructor( } override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" + "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" + } + + class PriceType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE_PRICE = PriceType(JsonField.of("usage_price")) + + @JvmField val FIXED_PRICE = PriceType(JsonField.of("fixed_price")) + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + fun asString(): String = _value().asStringOrThrow() } override fun equals(other: Any?): Boolean { @@ -24492,25 +26286,25 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageWithMinimumPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.packageWithAllocationConfig == other.packageWithAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredPackageWithMinimumConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, packageWithAllocationConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "TieredPackageWithMinimumPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, additionalProperties=$additionalProperties}" + "PackageWithAllocationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, packageWithAllocationConfig=$packageWithAllocationConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = PackageWithAllocationPrice.Builder::class) + @JsonDeserialize(builder = UnitWithPercentPrice.Builder::class) @NoAutoDetect - class PackageWithAllocationPrice + class UnitWithPercentPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -24534,7 +26328,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val packageWithAllocationConfig: JsonField, + private val unitWithPercentConfig: JsonField, private val additionalProperties: Map, ) { @@ -24601,8 +26395,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -24661,15 +26455,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("package_with_allocation_config") + @JsonProperty("unit_with_percent_config") @ExcludeMissing - fun _packageWithAllocationConfig() = packageWithAllocationConfig + fun _unitWithPercentConfig() = unitWithPercentConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): PackageWithAllocationPrice = apply { + fun validate(): UnitWithPercentPrice = apply { if (!validated) { metadata().validate() id() @@ -24693,7 +26487,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - packageWithAllocationConfig().validate() + unitWithPercentConfig().validate() validated = true } } @@ -24731,39 +26525,35 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var packageWithAllocationConfig: JsonField = - JsonMissing.of() + private var unitWithPercentConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(packageWithAllocationPrice: PackageWithAllocationPrice) = apply { - this.metadata = packageWithAllocationPrice.metadata - this.id = packageWithAllocationPrice.id - this.name = packageWithAllocationPrice.name - this.externalPriceId = packageWithAllocationPrice.externalPriceId - this.priceType = packageWithAllocationPrice.priceType - this.modelType = packageWithAllocationPrice.modelType - this.createdAt = packageWithAllocationPrice.createdAt - this.cadence = packageWithAllocationPrice.cadence - this.billingCycleConfiguration = - packageWithAllocationPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = - packageWithAllocationPrice.invoicingCycleConfiguration - this.billableMetric = packageWithAllocationPrice.billableMetric - this.fixedPriceQuantity = packageWithAllocationPrice.fixedPriceQuantity - this.planPhaseOrder = packageWithAllocationPrice.planPhaseOrder - this.currency = packageWithAllocationPrice.currency - this.conversionRate = packageWithAllocationPrice.conversionRate - this.item = packageWithAllocationPrice.item - this.creditAllocation = packageWithAllocationPrice.creditAllocation - this.discount = packageWithAllocationPrice.discount - this.minimum = packageWithAllocationPrice.minimum - this.minimumAmount = packageWithAllocationPrice.minimumAmount - this.maximum = packageWithAllocationPrice.maximum - this.maximumAmount = packageWithAllocationPrice.maximumAmount - this.packageWithAllocationConfig = - packageWithAllocationPrice.packageWithAllocationConfig - additionalProperties(packageWithAllocationPrice.additionalProperties) + internal fun from(unitWithPercentPrice: UnitWithPercentPrice) = apply { + this.metadata = unitWithPercentPrice.metadata + this.id = unitWithPercentPrice.id + this.name = unitWithPercentPrice.name + this.externalPriceId = unitWithPercentPrice.externalPriceId + this.priceType = unitWithPercentPrice.priceType + this.modelType = unitWithPercentPrice.modelType + this.createdAt = unitWithPercentPrice.createdAt + this.cadence = unitWithPercentPrice.cadence + this.billingCycleConfiguration = unitWithPercentPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = unitWithPercentPrice.invoicingCycleConfiguration + this.billableMetric = unitWithPercentPrice.billableMetric + this.fixedPriceQuantity = unitWithPercentPrice.fixedPriceQuantity + this.planPhaseOrder = unitWithPercentPrice.planPhaseOrder + this.currency = unitWithPercentPrice.currency + this.conversionRate = unitWithPercentPrice.conversionRate + this.item = unitWithPercentPrice.item + this.creditAllocation = unitWithPercentPrice.creditAllocation + this.discount = unitWithPercentPrice.discount + this.minimum = unitWithPercentPrice.minimum + this.minimumAmount = unitWithPercentPrice.minimumAmount + this.maximum = unitWithPercentPrice.maximum + this.maximumAmount = unitWithPercentPrice.maximumAmount + this.unitWithPercentConfig = unitWithPercentPrice.unitWithPercentConfig + additionalProperties(unitWithPercentPrice.additionalProperties) } /** @@ -24938,15 +26728,15 @@ private constructor( this.maximumAmount = maximumAmount } - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - @JsonProperty("package_with_allocation_config") + @JsonProperty("unit_with_percent_config") @ExcludeMissing - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = + apply { + this.unitWithPercentConfig = unitWithPercentConfig + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24962,8 +26752,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PackageWithAllocationPrice = - PackageWithAllocationPrice( + fun build(): UnitWithPercentPrice = + UnitWithPercentPrice( metadata, id, name, @@ -24986,7 +26776,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - packageWithAllocationConfig, + unitWithPercentConfig, additionalProperties.toUnmodifiable(), ) } @@ -26085,39 +27875,95 @@ private constructor( companion object { - @JvmField - val PACKAGE_WITH_ALLOCATION = ModelType(JsonField.of("package_with_allocation")) + @JvmField val UNIT_WITH_PERCENT = ModelType(JsonField.of("unit_with_percent")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - PACKAGE_WITH_ALLOCATION, + UNIT_WITH_PERCENT, } enum class Value { - PACKAGE_WITH_ALLOCATION, + UNIT_WITH_PERCENT, _UNKNOWN, } fun value(): Value = when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION + UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT else -> Value._UNKNOWN } fun known(): Known = when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION + UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT else -> throw OrbInvalidDataException("Unknown ModelType: $value") } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = PackageWithAllocationConfig.Builder::class) + class PriceType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE_PRICE = PriceType(JsonField.of("usage_price")) + + @JvmField val FIXED_PRICE = PriceType(JsonField.of("fixed_price")) + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = UnitWithPercentConfig.Builder::class) @NoAutoDetect - class PackageWithAllocationConfig + class UnitWithPercentConfig private constructor( private val additionalProperties: Map, ) { @@ -26128,7 +27974,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): PackageWithAllocationConfig = apply { + fun validate(): UnitWithPercentConfig = apply { if (!validated) { validated = true } @@ -26146,10 +27992,9 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = - apply { - additionalProperties(packageWithAllocationConfig.additionalProperties) - } + internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { + additionalProperties(unitWithPercentConfig.additionalProperties) + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -26166,8 +28011,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + fun build(): UnitWithPercentConfig = + UnitWithPercentConfig(additionalProperties.toUnmodifiable()) } override fun equals(other: Any?): Boolean { @@ -26175,7 +28020,7 @@ private constructor( return true } - return /* spotless:off */ other is PackageWithAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercentConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -26188,64 +28033,7 @@ private constructor( } override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - - class PriceType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USAGE_PRICE = PriceType(JsonField.of("usage_price")) - - @JvmField val FIXED_PRICE = PriceType(JsonField.of("fixed_price")) - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - fun asString(): String = _value().asStringOrThrow() + "UnitWithPercentConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -26253,25 +28041,25 @@ private constructor( return true } - return /* spotless:off */ other is PackageWithAllocationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.packageWithAllocationConfig == other.packageWithAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercentPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.unitWithPercentConfig == other.unitWithPercentConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, packageWithAllocationConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, unitWithPercentConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "PackageWithAllocationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, packageWithAllocationConfig=$packageWithAllocationConfig, additionalProperties=$additionalProperties}" + "UnitWithPercentPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, unitWithPercentConfig=$unitWithPercentConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = UnitWithPercentPrice.Builder::class) + @JsonDeserialize(builder = MatrixWithAllocationPrice.Builder::class) @NoAutoDetect - class UnitWithPercentPrice + class MatrixWithAllocationPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -26295,7 +28083,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val unitWithPercentConfig: JsonField, + private val matrixWithAllocationConfig: JsonField, private val additionalProperties: Map, ) { @@ -26362,8 +28150,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -26422,15 +28210,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("unit_with_percent_config") + @JsonProperty("matrix_with_allocation_config") @ExcludeMissing - fun _unitWithPercentConfig() = unitWithPercentConfig + fun _matrixWithAllocationConfig() = matrixWithAllocationConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnitWithPercentPrice = apply { + fun validate(): MatrixWithAllocationPrice = apply { if (!validated) { metadata().validate() id() @@ -26454,7 +28242,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - unitWithPercentConfig().validate() + matrixWithAllocationConfig().validate() validated = true } } @@ -26492,35 +28280,38 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var unitWithPercentConfig: JsonField = JsonMissing.of() + private var matrixWithAllocationConfig: JsonField = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitWithPercentPrice: UnitWithPercentPrice) = apply { - this.metadata = unitWithPercentPrice.metadata - this.id = unitWithPercentPrice.id - this.name = unitWithPercentPrice.name - this.externalPriceId = unitWithPercentPrice.externalPriceId - this.priceType = unitWithPercentPrice.priceType - this.modelType = unitWithPercentPrice.modelType - this.createdAt = unitWithPercentPrice.createdAt - this.cadence = unitWithPercentPrice.cadence - this.billingCycleConfiguration = unitWithPercentPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = unitWithPercentPrice.invoicingCycleConfiguration - this.billableMetric = unitWithPercentPrice.billableMetric - this.fixedPriceQuantity = unitWithPercentPrice.fixedPriceQuantity - this.planPhaseOrder = unitWithPercentPrice.planPhaseOrder - this.currency = unitWithPercentPrice.currency - this.conversionRate = unitWithPercentPrice.conversionRate - this.item = unitWithPercentPrice.item - this.creditAllocation = unitWithPercentPrice.creditAllocation - this.discount = unitWithPercentPrice.discount - this.minimum = unitWithPercentPrice.minimum - this.minimumAmount = unitWithPercentPrice.minimumAmount - this.maximum = unitWithPercentPrice.maximum - this.maximumAmount = unitWithPercentPrice.maximumAmount - this.unitWithPercentConfig = unitWithPercentPrice.unitWithPercentConfig - additionalProperties(unitWithPercentPrice.additionalProperties) + internal fun from(matrixWithAllocationPrice: MatrixWithAllocationPrice) = apply { + this.metadata = matrixWithAllocationPrice.metadata + this.id = matrixWithAllocationPrice.id + this.name = matrixWithAllocationPrice.name + this.externalPriceId = matrixWithAllocationPrice.externalPriceId + this.priceType = matrixWithAllocationPrice.priceType + this.modelType = matrixWithAllocationPrice.modelType + this.createdAt = matrixWithAllocationPrice.createdAt + this.cadence = matrixWithAllocationPrice.cadence + this.billingCycleConfiguration = matrixWithAllocationPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + matrixWithAllocationPrice.invoicingCycleConfiguration + this.billableMetric = matrixWithAllocationPrice.billableMetric + this.fixedPriceQuantity = matrixWithAllocationPrice.fixedPriceQuantity + this.planPhaseOrder = matrixWithAllocationPrice.planPhaseOrder + this.currency = matrixWithAllocationPrice.currency + this.conversionRate = matrixWithAllocationPrice.conversionRate + this.item = matrixWithAllocationPrice.item + this.creditAllocation = matrixWithAllocationPrice.creditAllocation + this.discount = matrixWithAllocationPrice.discount + this.minimum = matrixWithAllocationPrice.minimum + this.minimumAmount = matrixWithAllocationPrice.minimumAmount + this.maximum = matrixWithAllocationPrice.maximum + this.maximumAmount = matrixWithAllocationPrice.maximumAmount + this.matrixWithAllocationConfig = + matrixWithAllocationPrice.matrixWithAllocationConfig + additionalProperties(matrixWithAllocationPrice.additionalProperties) } /** @@ -26695,15 +28486,14 @@ private constructor( this.maximumAmount = maximumAmount } - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = + matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) - @JsonProperty("unit_with_percent_config") + @JsonProperty("matrix_with_allocation_config") @ExcludeMissing - fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -26719,8 +28509,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): UnitWithPercentPrice = - UnitWithPercentPrice( + fun build(): MatrixWithAllocationPrice = + MatrixWithAllocationPrice( metadata, id, name, @@ -26743,7 +28533,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - unitWithPercentConfig, + matrixWithAllocationConfig, additionalProperties.toUnmodifiable(), ) } @@ -27470,6 +29260,314 @@ private constructor( "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" } + @JsonDeserialize(builder = MatrixWithAllocationConfig.Builder::class) + @NoAutoDetect + class MatrixWithAllocationConfig + private constructor( + private val dimensions: JsonField>, + private val defaultUnitAmount: JsonField, + private val matrixValues: JsonField>, + private val allocation: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = matrixValues.getRequired("matrix_values") + + /** Allocation to be used to calculate the price */ + fun allocation(): Double = allocation.getRequired("allocation") + + /** One or two event property values to evaluate matrix groups by */ + @JsonProperty("dimensions") @ExcludeMissing fun _dimensions() = dimensions + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount() = defaultUnitAmount + + /** Matrix values for specified matrix grouping keys */ + @JsonProperty("matrix_values") @ExcludeMissing fun _matrixValues() = matrixValues + + /** Allocation to be used to calculate the price */ + @JsonProperty("allocation") @ExcludeMissing fun _allocation() = allocation + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MatrixWithAllocationConfig = apply { + if (!validated) { + dimensions() + defaultUnitAmount() + matrixValues().forEach { it.validate() } + allocation() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var dimensions: JsonField> = JsonMissing.of() + private var defaultUnitAmount: JsonField = JsonMissing.of() + private var matrixValues: JsonField> = JsonMissing.of() + private var allocation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithAllocationConfig: MatrixWithAllocationConfig) = apply { + this.dimensions = matrixWithAllocationConfig.dimensions + this.defaultUnitAmount = matrixWithAllocationConfig.defaultUnitAmount + this.matrixValues = matrixWithAllocationConfig.matrixValues + this.allocation = matrixWithAllocationConfig.allocation + additionalProperties(matrixWithAllocationConfig.additionalProperties) + } + + /** 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 */ + @JsonProperty("dimensions") + @ExcludeMissing + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions + } + + /** + * 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 + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues + } + + /** Allocation to be used to calculate the price */ + fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) + + /** Allocation to be used to calculate the price */ + @JsonProperty("allocation") + @ExcludeMissing + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MatrixWithAllocationConfig = + MatrixWithAllocationConfig( + dimensions.map { it.toUnmodifiable() }, + defaultUnitAmount, + matrixValues.map { it.toUnmodifiable() }, + allocation, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = MatrixValue.Builder::class) + @NoAutoDetect + class MatrixValue + private constructor( + private val unitAmount: JsonField, + private val dimensionValues: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** 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. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + + /** + * 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() = dimensionValues + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MatrixValue = apply { + if (!validated) { + unitAmount() + dimensionValues() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var unitAmount: JsonField = JsonMissing.of() + private var dimensionValues: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + this.unitAmount = matrixValue.unitAmount + this.dimensionValues = matrixValue.dimensionValues + additionalProperties(matrixValue.additionalProperties) + } + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** + * 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. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MatrixValue = + MatrixValue( + unitAmount, + dimensionValues.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixValue && this.unitAmount == other.unitAmount && this.dimensionValues == other.dimensionValues && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(unitAmount, dimensionValues, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MatrixValue{unitAmount=$unitAmount, dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixWithAllocationConfig && this.dimensions == other.dimensions && this.defaultUnitAmount == other.defaultUnitAmount && this.matrixValues == other.matrixValues && this.allocation == other.allocation && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(dimensions, defaultUnitAmount, matrixValues, allocation, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MatrixWithAllocationConfig{dimensions=$dimensions, defaultUnitAmount=$defaultUnitAmount, matrixValues=$matrixValues, allocation=$allocation, additionalProperties=$additionalProperties}" + } + @JsonDeserialize(builder = Maximum.Builder::class) @NoAutoDetect class Maximum @@ -27842,29 +29940,30 @@ private constructor( companion object { - @JvmField val UNIT_WITH_PERCENT = ModelType(JsonField.of("unit_with_percent")) + @JvmField + val MATRIX_WITH_ALLOCATION = ModelType(JsonField.of("matrix_with_allocation")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - UNIT_WITH_PERCENT, + MATRIX_WITH_ALLOCATION, } enum class Value { - UNIT_WITH_PERCENT, + MATRIX_WITH_ALLOCATION, _UNKNOWN, } fun value(): Value = when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT + MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION else -> Value._UNKNOWN } fun known(): Known = when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT + MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -27928,105 +30027,30 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnitWithPercentConfig.Builder::class) - @NoAutoDetect - class UnitWithPercentConfig - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnitWithPercentConfig = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties(unitWithPercentConfig.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithPercentConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithPercentPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.unitWithPercentConfig == other.unitWithPercentConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithAllocationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.matrixWithAllocationConfig == other.matrixWithAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, unitWithPercentConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, matrixWithAllocationConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "UnitWithPercentPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, unitWithPercentConfig=$unitWithPercentConfig, additionalProperties=$additionalProperties}" + "MatrixWithAllocationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, matrixWithAllocationConfig=$matrixWithAllocationConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = MatrixWithAllocationPrice.Builder::class) + @JsonDeserialize(builder = TieredWithProrationPrice.Builder::class) @NoAutoDetect - class MatrixWithAllocationPrice + class TieredWithProrationPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -28050,7 +30074,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val matrixWithAllocationConfig: JsonField, + private val tieredWithProrationConfig: JsonField, private val additionalProperties: Map, ) { @@ -28117,8 +30141,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = - matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -28177,15 +30201,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("matrix_with_allocation_config") + @JsonProperty("tiered_with_proration_config") @ExcludeMissing - fun _matrixWithAllocationConfig() = matrixWithAllocationConfig + fun _tieredWithProrationConfig() = tieredWithProrationConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): MatrixWithAllocationPrice = apply { + fun validate(): TieredWithProrationPrice = apply { if (!validated) { metadata().validate() id() @@ -28209,7 +30233,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - matrixWithAllocationConfig().validate() + tieredWithProrationConfig().validate() validated = true } } @@ -28247,38 +30271,37 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var matrixWithAllocationConfig: JsonField = + private var tieredWithProrationConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixWithAllocationPrice: MatrixWithAllocationPrice) = apply { - this.metadata = matrixWithAllocationPrice.metadata - this.id = matrixWithAllocationPrice.id - this.name = matrixWithAllocationPrice.name - this.externalPriceId = matrixWithAllocationPrice.externalPriceId - this.priceType = matrixWithAllocationPrice.priceType - this.modelType = matrixWithAllocationPrice.modelType - this.createdAt = matrixWithAllocationPrice.createdAt - this.cadence = matrixWithAllocationPrice.cadence - this.billingCycleConfiguration = matrixWithAllocationPrice.billingCycleConfiguration + internal fun from(tieredWithProrationPrice: TieredWithProrationPrice) = apply { + this.metadata = tieredWithProrationPrice.metadata + this.id = tieredWithProrationPrice.id + this.name = tieredWithProrationPrice.name + this.externalPriceId = tieredWithProrationPrice.externalPriceId + this.priceType = tieredWithProrationPrice.priceType + this.modelType = tieredWithProrationPrice.modelType + this.createdAt = tieredWithProrationPrice.createdAt + this.cadence = tieredWithProrationPrice.cadence + this.billingCycleConfiguration = tieredWithProrationPrice.billingCycleConfiguration this.invoicingCycleConfiguration = - matrixWithAllocationPrice.invoicingCycleConfiguration - this.billableMetric = matrixWithAllocationPrice.billableMetric - this.fixedPriceQuantity = matrixWithAllocationPrice.fixedPriceQuantity - this.planPhaseOrder = matrixWithAllocationPrice.planPhaseOrder - this.currency = matrixWithAllocationPrice.currency - this.conversionRate = matrixWithAllocationPrice.conversionRate - this.item = matrixWithAllocationPrice.item - this.creditAllocation = matrixWithAllocationPrice.creditAllocation - this.discount = matrixWithAllocationPrice.discount - this.minimum = matrixWithAllocationPrice.minimum - this.minimumAmount = matrixWithAllocationPrice.minimumAmount - this.maximum = matrixWithAllocationPrice.maximum - this.maximumAmount = matrixWithAllocationPrice.maximumAmount - this.matrixWithAllocationConfig = - matrixWithAllocationPrice.matrixWithAllocationConfig - additionalProperties(matrixWithAllocationPrice.additionalProperties) + tieredWithProrationPrice.invoicingCycleConfiguration + this.billableMetric = tieredWithProrationPrice.billableMetric + this.fixedPriceQuantity = tieredWithProrationPrice.fixedPriceQuantity + this.planPhaseOrder = tieredWithProrationPrice.planPhaseOrder + this.currency = tieredWithProrationPrice.currency + this.conversionRate = tieredWithProrationPrice.conversionRate + this.item = tieredWithProrationPrice.item + this.creditAllocation = tieredWithProrationPrice.creditAllocation + this.discount = tieredWithProrationPrice.discount + this.minimum = tieredWithProrationPrice.minimum + this.minimumAmount = tieredWithProrationPrice.minimumAmount + this.maximum = tieredWithProrationPrice.maximum + this.maximumAmount = tieredWithProrationPrice.maximumAmount + this.tieredWithProrationConfig = tieredWithProrationPrice.tieredWithProrationConfig + additionalProperties(tieredWithProrationPrice.additionalProperties) } /** @@ -28453,14 +30476,14 @@ private constructor( this.maximumAmount = maximumAmount } - fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = - matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = + tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - @JsonProperty("matrix_with_allocation_config") + @JsonProperty("tiered_with_proration_config") @ExcludeMissing - fun matrixWithAllocationConfig( - matrixWithAllocationConfig: JsonField - ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -28476,8 +30499,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MatrixWithAllocationPrice = - MatrixWithAllocationPrice( + fun build(): TieredWithProrationPrice = + TieredWithProrationPrice( metadata, id, name, @@ -28500,7 +30523,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - matrixWithAllocationConfig, + tieredWithProrationConfig, additionalProperties.toUnmodifiable(), ) } @@ -29227,314 +31250,6 @@ private constructor( "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = MatrixWithAllocationConfig.Builder::class) - @NoAutoDetect - class MatrixWithAllocationConfig - private constructor( - private val dimensions: JsonField>, - private val defaultUnitAmount: JsonField, - private val matrixValues: JsonField>, - private val allocation: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = matrixValues.getRequired("matrix_values") - - /** Allocation to be used to calculate the price */ - fun allocation(): Double = allocation.getRequired("allocation") - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") @ExcludeMissing fun _dimensions() = dimensions - - /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount() = defaultUnitAmount - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") @ExcludeMissing fun _matrixValues() = matrixValues - - /** Allocation to be used to calculate the price */ - @JsonProperty("allocation") @ExcludeMissing fun _allocation() = allocation - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MatrixWithAllocationConfig = apply { - if (!validated) { - dimensions() - defaultUnitAmount() - matrixValues().forEach { it.validate() } - allocation() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var dimensions: JsonField> = JsonMissing.of() - private var defaultUnitAmount: JsonField = JsonMissing.of() - private var matrixValues: JsonField> = JsonMissing.of() - private var allocation: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixWithAllocationConfig: MatrixWithAllocationConfig) = apply { - this.dimensions = matrixWithAllocationConfig.dimensions - this.defaultUnitAmount = matrixWithAllocationConfig.defaultUnitAmount - this.matrixValues = matrixWithAllocationConfig.matrixValues - this.allocation = matrixWithAllocationConfig.allocation - additionalProperties(matrixWithAllocationConfig.additionalProperties) - } - - /** 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 */ - @JsonProperty("dimensions") - @ExcludeMissing - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions - } - - /** - * 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 - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { - this.defaultUnitAmount = defaultUnitAmount - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues - } - - /** Allocation to be used to calculate the price */ - fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) - - /** Allocation to be used to calculate the price */ - @JsonProperty("allocation") - @ExcludeMissing - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MatrixWithAllocationConfig = - MatrixWithAllocationConfig( - dimensions.map { it.toUnmodifiable() }, - defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - allocation, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = MatrixValue.Builder::class) - @NoAutoDetect - class MatrixValue - private constructor( - private val unitAmount: JsonField, - private val dimensionValues: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** 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. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount - - /** - * 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() = dimensionValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MatrixValue = apply { - if (!validated) { - unitAmount() - dimensionValues() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var unitAmount: JsonField = JsonMissing.of() - private var dimensionValues: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - this.unitAmount = matrixValue.unitAmount - this.dimensionValues = matrixValue.dimensionValues - additionalProperties(matrixValue.additionalProperties) - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * 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. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MatrixValue = - MatrixValue( - unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && this.unitAmount == other.unitAmount && this.dimensionValues == other.dimensionValues && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(unitAmount, dimensionValues, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "MatrixValue{unitAmount=$unitAmount, dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixWithAllocationConfig && this.dimensions == other.dimensions && this.defaultUnitAmount == other.defaultUnitAmount && this.matrixValues == other.matrixValues && this.allocation == other.allocation && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(dimensions, defaultUnitAmount, matrixValues, allocation, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "MatrixWithAllocationConfig{dimensions=$dimensions, defaultUnitAmount=$defaultUnitAmount, matrixValues=$matrixValues, allocation=$allocation, additionalProperties=$additionalProperties}" - } - @JsonDeserialize(builder = Maximum.Builder::class) @NoAutoDetect class Maximum @@ -29908,29 +31623,29 @@ private constructor( companion object { @JvmField - val MATRIX_WITH_ALLOCATION = ModelType(JsonField.of("matrix_with_allocation")) + val TIERED_WITH_PRORATION = ModelType(JsonField.of("tiered_with_proration")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - MATRIX_WITH_ALLOCATION, + TIERED_WITH_PRORATION, } enum class Value { - MATRIX_WITH_ALLOCATION, + TIERED_WITH_PRORATION, _UNKNOWN, } fun value(): Value = when (this) { - MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION + TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION else -> Value._UNKNOWN } fun known(): Known = when (this) { - MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION + TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -29994,30 +31709,105 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + @JsonDeserialize(builder = TieredWithProrationConfig.Builder::class) + @NoAutoDetect + class TieredWithProrationConfig + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TieredWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { + additionalProperties(tieredWithProrationConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredWithProrationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "TieredWithProrationConfig{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MatrixWithAllocationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.matrixWithAllocationConfig == other.matrixWithAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithProrationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredWithProrationConfig == other.tieredWithProrationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, matrixWithAllocationConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredWithProrationConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "MatrixWithAllocationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, matrixWithAllocationConfig=$matrixWithAllocationConfig, additionalProperties=$additionalProperties}" + "TieredWithProrationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredWithProrationConfig=$tieredWithProrationConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = TieredWithProrationPrice.Builder::class) + @JsonDeserialize(builder = UnitWithProrationPrice.Builder::class) @NoAutoDetect - class TieredWithProrationPrice + class UnitWithProrationPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -30041,7 +31831,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val tieredWithProrationConfig: JsonField, + private val unitWithProrationConfig: JsonField, private val additionalProperties: Map, ) { @@ -30108,8 +31898,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -30168,15 +31958,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("tiered_with_proration_config") + @JsonProperty("unit_with_proration_config") @ExcludeMissing - fun _tieredWithProrationConfig() = tieredWithProrationConfig + fun _unitWithProrationConfig() = unitWithProrationConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredWithProrationPrice = apply { + fun validate(): UnitWithProrationPrice = apply { if (!validated) { metadata().validate() id() @@ -30200,7 +31990,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - tieredWithProrationConfig().validate() + unitWithProrationConfig().validate() validated = true } } @@ -30238,37 +32028,37 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var tieredWithProrationConfig: JsonField = + private var unitWithProrationConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationPrice: TieredWithProrationPrice) = apply { - this.metadata = tieredWithProrationPrice.metadata - this.id = tieredWithProrationPrice.id - this.name = tieredWithProrationPrice.name - this.externalPriceId = tieredWithProrationPrice.externalPriceId - this.priceType = tieredWithProrationPrice.priceType - this.modelType = tieredWithProrationPrice.modelType - this.createdAt = tieredWithProrationPrice.createdAt - this.cadence = tieredWithProrationPrice.cadence - this.billingCycleConfiguration = tieredWithProrationPrice.billingCycleConfiguration + internal fun from(unitWithProrationPrice: UnitWithProrationPrice) = apply { + this.metadata = unitWithProrationPrice.metadata + this.id = unitWithProrationPrice.id + this.name = unitWithProrationPrice.name + this.externalPriceId = unitWithProrationPrice.externalPriceId + this.priceType = unitWithProrationPrice.priceType + this.modelType = unitWithProrationPrice.modelType + this.createdAt = unitWithProrationPrice.createdAt + this.cadence = unitWithProrationPrice.cadence + this.billingCycleConfiguration = unitWithProrationPrice.billingCycleConfiguration this.invoicingCycleConfiguration = - tieredWithProrationPrice.invoicingCycleConfiguration - this.billableMetric = tieredWithProrationPrice.billableMetric - this.fixedPriceQuantity = tieredWithProrationPrice.fixedPriceQuantity - this.planPhaseOrder = tieredWithProrationPrice.planPhaseOrder - this.currency = tieredWithProrationPrice.currency - this.conversionRate = tieredWithProrationPrice.conversionRate - this.item = tieredWithProrationPrice.item - this.creditAllocation = tieredWithProrationPrice.creditAllocation - this.discount = tieredWithProrationPrice.discount - this.minimum = tieredWithProrationPrice.minimum - this.minimumAmount = tieredWithProrationPrice.minimumAmount - this.maximum = tieredWithProrationPrice.maximum - this.maximumAmount = tieredWithProrationPrice.maximumAmount - this.tieredWithProrationConfig = tieredWithProrationPrice.tieredWithProrationConfig - additionalProperties(tieredWithProrationPrice.additionalProperties) + unitWithProrationPrice.invoicingCycleConfiguration + this.billableMetric = unitWithProrationPrice.billableMetric + this.fixedPriceQuantity = unitWithProrationPrice.fixedPriceQuantity + this.planPhaseOrder = unitWithProrationPrice.planPhaseOrder + this.currency = unitWithProrationPrice.currency + this.conversionRate = unitWithProrationPrice.conversionRate + this.item = unitWithProrationPrice.item + this.creditAllocation = unitWithProrationPrice.creditAllocation + this.discount = unitWithProrationPrice.discount + this.minimum = unitWithProrationPrice.minimum + this.minimumAmount = unitWithProrationPrice.minimumAmount + this.maximum = unitWithProrationPrice.maximum + this.maximumAmount = unitWithProrationPrice.maximumAmount + this.unitWithProrationConfig = unitWithProrationPrice.unitWithProrationConfig + additionalProperties(unitWithProrationPrice.additionalProperties) } /** @@ -30443,14 +32233,14 @@ private constructor( this.maximumAmount = maximumAmount } - fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = - tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) - @JsonProperty("tiered_with_proration_config") + @JsonProperty("unit_with_proration_config") @ExcludeMissing - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -30466,8 +32256,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredWithProrationPrice = - TieredWithProrationPrice( + fun build(): UnitWithProrationPrice = + UnitWithProrationPrice( metadata, id, name, @@ -30490,7 +32280,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - tieredWithProrationConfig, + unitWithProrationConfig, additionalProperties.toUnmodifiable(), ) } @@ -31589,30 +33379,29 @@ private constructor( companion object { - @JvmField - val TIERED_WITH_PRORATION = ModelType(JsonField.of("tiered_with_proration")) + @JvmField val UNIT_WITH_PRORATION = ModelType(JsonField.of("unit_with_proration")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - TIERED_WITH_PRORATION, + UNIT_WITH_PRORATION, } enum class Value { - TIERED_WITH_PRORATION, + UNIT_WITH_PRORATION, _UNKNOWN, } fun value(): Value = when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION + UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION else -> Value._UNKNOWN } fun known(): Known = when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION + UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -31676,9 +33465,9 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = TieredWithProrationConfig.Builder::class) + @JsonDeserialize(builder = UnitWithProrationConfig.Builder::class) @NoAutoDetect - class TieredWithProrationConfig + class UnitWithProrationConfig private constructor( private val additionalProperties: Map, ) { @@ -31689,7 +33478,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): TieredWithProrationConfig = apply { + fun validate(): UnitWithProrationConfig = apply { if (!validated) { validated = true } @@ -31707,8 +33496,8 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { - additionalProperties(tieredWithProrationConfig.additionalProperties) + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { + additionalProperties(unitWithProrationConfig.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -31726,8 +33515,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig(additionalProperties.toUnmodifiable()) } override fun equals(other: Any?): Boolean { @@ -31735,7 +33524,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithProrationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProrationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -31748,7 +33537,7 @@ private constructor( } override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" + "UnitWithProrationConfig{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -31756,25 +33545,25 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithProrationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.tieredWithProrationConfig == other.tieredWithProrationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProrationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.unitWithProrationConfig == other.unitWithProrationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, tieredWithProrationConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, unitWithProrationConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "TieredWithProrationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, tieredWithProrationConfig=$tieredWithProrationConfig, additionalProperties=$additionalProperties}" + "UnitWithProrationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, unitWithProrationConfig=$unitWithProrationConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = UnitWithProrationPrice.Builder::class) + @JsonDeserialize(builder = GroupedAllocationPrice.Builder::class) @NoAutoDetect - class UnitWithProrationPrice + class GroupedAllocationPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -31798,7 +33587,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val unitWithProrationConfig: JsonField, + private val groupedAllocationConfig: JsonField, private val additionalProperties: Map, ) { @@ -31865,8 +33654,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -31925,15 +33714,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("unit_with_proration_config") + @JsonProperty("grouped_allocation_config") @ExcludeMissing - fun _unitWithProrationConfig() = unitWithProrationConfig + fun _groupedAllocationConfig() = groupedAllocationConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnitWithProrationPrice = apply { + fun validate(): GroupedAllocationPrice = apply { if (!validated) { metadata().validate() id() @@ -31957,7 +33746,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - unitWithProrationConfig().validate() + groupedAllocationConfig().validate() validated = true } } @@ -31995,37 +33784,37 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var unitWithProrationConfig: JsonField = + private var groupedAllocationConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitWithProrationPrice: UnitWithProrationPrice) = apply { - this.metadata = unitWithProrationPrice.metadata - this.id = unitWithProrationPrice.id - this.name = unitWithProrationPrice.name - this.externalPriceId = unitWithProrationPrice.externalPriceId - this.priceType = unitWithProrationPrice.priceType - this.modelType = unitWithProrationPrice.modelType - this.createdAt = unitWithProrationPrice.createdAt - this.cadence = unitWithProrationPrice.cadence - this.billingCycleConfiguration = unitWithProrationPrice.billingCycleConfiguration + internal fun from(groupedAllocationPrice: GroupedAllocationPrice) = apply { + this.metadata = groupedAllocationPrice.metadata + this.id = groupedAllocationPrice.id + this.name = groupedAllocationPrice.name + this.externalPriceId = groupedAllocationPrice.externalPriceId + this.priceType = groupedAllocationPrice.priceType + this.modelType = groupedAllocationPrice.modelType + this.createdAt = groupedAllocationPrice.createdAt + this.cadence = groupedAllocationPrice.cadence + this.billingCycleConfiguration = groupedAllocationPrice.billingCycleConfiguration this.invoicingCycleConfiguration = - unitWithProrationPrice.invoicingCycleConfiguration - this.billableMetric = unitWithProrationPrice.billableMetric - this.fixedPriceQuantity = unitWithProrationPrice.fixedPriceQuantity - this.planPhaseOrder = unitWithProrationPrice.planPhaseOrder - this.currency = unitWithProrationPrice.currency - this.conversionRate = unitWithProrationPrice.conversionRate - this.item = unitWithProrationPrice.item - this.creditAllocation = unitWithProrationPrice.creditAllocation - this.discount = unitWithProrationPrice.discount - this.minimum = unitWithProrationPrice.minimum - this.minimumAmount = unitWithProrationPrice.minimumAmount - this.maximum = unitWithProrationPrice.maximum - this.maximumAmount = unitWithProrationPrice.maximumAmount - this.unitWithProrationConfig = unitWithProrationPrice.unitWithProrationConfig - additionalProperties(unitWithProrationPrice.additionalProperties) + groupedAllocationPrice.invoicingCycleConfiguration + this.billableMetric = groupedAllocationPrice.billableMetric + this.fixedPriceQuantity = groupedAllocationPrice.fixedPriceQuantity + this.planPhaseOrder = groupedAllocationPrice.planPhaseOrder + this.currency = groupedAllocationPrice.currency + this.conversionRate = groupedAllocationPrice.conversionRate + this.item = groupedAllocationPrice.item + this.creditAllocation = groupedAllocationPrice.creditAllocation + this.discount = groupedAllocationPrice.discount + this.minimum = groupedAllocationPrice.minimum + this.minimumAmount = groupedAllocationPrice.minimumAmount + this.maximum = groupedAllocationPrice.maximum + this.maximumAmount = groupedAllocationPrice.maximumAmount + this.groupedAllocationConfig = groupedAllocationPrice.groupedAllocationConfig + additionalProperties(groupedAllocationPrice.additionalProperties) } /** @@ -32200,14 +33989,14 @@ private constructor( this.maximumAmount = maximumAmount } - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - @JsonProperty("unit_with_proration_config") + @JsonProperty("grouped_allocation_config") @ExcludeMissing - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -32223,8 +34012,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): UnitWithProrationPrice = - UnitWithProrationPrice( + fun build(): GroupedAllocationPrice = + GroupedAllocationPrice( metadata, id, name, @@ -32247,7 +34036,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - unitWithProrationConfig, + groupedAllocationConfig, additionalProperties.toUnmodifiable(), ) } @@ -32699,6 +34488,81 @@ private constructor( "CreditAllocation{currency=$currency, allowsRollover=$allowsRollover, additionalProperties=$additionalProperties}" } + @JsonDeserialize(builder = GroupedAllocationConfig.Builder::class) + @NoAutoDetect + class GroupedAllocationConfig + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): GroupedAllocationConfig = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + additionalProperties(groupedAllocationConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupedAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) @NoAutoDetect class InvoicingCycleConfiguration @@ -33346,29 +35210,29 @@ private constructor( companion object { - @JvmField val UNIT_WITH_PRORATION = ModelType(JsonField.of("unit_with_proration")) + @JvmField val GROUPED_ALLOCATION = ModelType(JsonField.of("grouped_allocation")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - UNIT_WITH_PRORATION, + GROUPED_ALLOCATION, } enum class Value { - UNIT_WITH_PRORATION, + GROUPED_ALLOCATION, _UNKNOWN, } fun value(): Value = when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION + GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION else -> Value._UNKNOWN } fun known(): Known = when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION + GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -33432,105 +35296,30 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnitWithProrationConfig.Builder::class) - @NoAutoDetect - class UnitWithProrationConfig - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): UnitWithProrationConfig = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { - additionalProperties(unitWithProrationConfig.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithProrationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.unitWithProrationConfig == other.unitWithProrationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.groupedAllocationConfig == other.groupedAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, unitWithProrationConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, groupedAllocationConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "UnitWithProrationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, unitWithProrationConfig=$unitWithProrationConfig, additionalProperties=$additionalProperties}" + "GroupedAllocationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, groupedAllocationConfig=$groupedAllocationConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GroupedAllocationPrice.Builder::class) + @JsonDeserialize(builder = GroupedWithProratedMinimumPrice.Builder::class) @NoAutoDetect - class GroupedAllocationPrice + class GroupedWithProratedMinimumPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -33554,7 +35343,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val groupedAllocationConfig: JsonField, + private val groupedWithProratedMinimumConfig: JsonField, private val additionalProperties: Map, ) { @@ -33621,8 +35410,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -33681,15 +35470,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("grouped_allocation_config") + @JsonProperty("grouped_with_prorated_minimum_config") @ExcludeMissing - fun _groupedAllocationConfig() = groupedAllocationConfig + fun _groupedWithProratedMinimumConfig() = groupedWithProratedMinimumConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): GroupedAllocationPrice = apply { + fun validate(): GroupedWithProratedMinimumPrice = apply { if (!validated) { metadata().validate() id() @@ -33713,7 +35502,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - groupedAllocationConfig().validate() + groupedWithProratedMinimumConfig().validate() validated = true } } @@ -33751,38 +35540,42 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var groupedAllocationConfig: JsonField = + private var groupedWithProratedMinimumConfig: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedAllocationPrice: GroupedAllocationPrice) = apply { - this.metadata = groupedAllocationPrice.metadata - this.id = groupedAllocationPrice.id - this.name = groupedAllocationPrice.name - this.externalPriceId = groupedAllocationPrice.externalPriceId - this.priceType = groupedAllocationPrice.priceType - this.modelType = groupedAllocationPrice.modelType - this.createdAt = groupedAllocationPrice.createdAt - this.cadence = groupedAllocationPrice.cadence - this.billingCycleConfiguration = groupedAllocationPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = - groupedAllocationPrice.invoicingCycleConfiguration - this.billableMetric = groupedAllocationPrice.billableMetric - this.fixedPriceQuantity = groupedAllocationPrice.fixedPriceQuantity - this.planPhaseOrder = groupedAllocationPrice.planPhaseOrder - this.currency = groupedAllocationPrice.currency - this.conversionRate = groupedAllocationPrice.conversionRate - this.item = groupedAllocationPrice.item - this.creditAllocation = groupedAllocationPrice.creditAllocation - this.discount = groupedAllocationPrice.discount - this.minimum = groupedAllocationPrice.minimum - this.minimumAmount = groupedAllocationPrice.minimumAmount - this.maximum = groupedAllocationPrice.maximum - this.maximumAmount = groupedAllocationPrice.maximumAmount - this.groupedAllocationConfig = groupedAllocationPrice.groupedAllocationConfig - additionalProperties(groupedAllocationPrice.additionalProperties) - } + internal fun from(groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice) = + apply { + this.metadata = groupedWithProratedMinimumPrice.metadata + this.id = groupedWithProratedMinimumPrice.id + this.name = groupedWithProratedMinimumPrice.name + this.externalPriceId = groupedWithProratedMinimumPrice.externalPriceId + this.priceType = groupedWithProratedMinimumPrice.priceType + this.modelType = groupedWithProratedMinimumPrice.modelType + this.createdAt = groupedWithProratedMinimumPrice.createdAt + this.cadence = groupedWithProratedMinimumPrice.cadence + this.billingCycleConfiguration = + groupedWithProratedMinimumPrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + groupedWithProratedMinimumPrice.invoicingCycleConfiguration + this.billableMetric = groupedWithProratedMinimumPrice.billableMetric + this.fixedPriceQuantity = groupedWithProratedMinimumPrice.fixedPriceQuantity + this.planPhaseOrder = groupedWithProratedMinimumPrice.planPhaseOrder + this.currency = groupedWithProratedMinimumPrice.currency + this.conversionRate = groupedWithProratedMinimumPrice.conversionRate + this.item = groupedWithProratedMinimumPrice.item + this.creditAllocation = groupedWithProratedMinimumPrice.creditAllocation + this.discount = groupedWithProratedMinimumPrice.discount + this.minimum = groupedWithProratedMinimumPrice.minimum + this.minimumAmount = groupedWithProratedMinimumPrice.minimumAmount + this.maximum = groupedWithProratedMinimumPrice.maximum + this.maximumAmount = groupedWithProratedMinimumPrice.maximumAmount + this.groupedWithProratedMinimumConfig = + groupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig + additionalProperties(groupedWithProratedMinimumPrice.additionalProperties) + } /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -33956,14 +35749,15 @@ private constructor( this.maximumAmount = maximumAmount } - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) - @JsonProperty("grouped_allocation_config") + @JsonProperty("grouped_with_prorated_minimum_config") @ExcludeMissing - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -33979,8 +35773,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupedAllocationPrice = - GroupedAllocationPrice( + fun build(): GroupedWithProratedMinimumPrice = + GroupedWithProratedMinimumPrice( metadata, id, name, @@ -34003,7 +35797,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - groupedAllocationConfig, + groupedWithProratedMinimumConfig, additionalProperties.toUnmodifiable(), ) } @@ -34455,9 +36249,9 @@ private constructor( "CreditAllocation{currency=$currency, allowsRollover=$allowsRollover, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GroupedAllocationConfig.Builder::class) + @JsonDeserialize(builder = GroupedWithProratedMinimumConfig.Builder::class) @NoAutoDetect - class GroupedAllocationConfig + class GroupedWithProratedMinimumConfig private constructor( private val additionalProperties: Map, ) { @@ -34468,7 +36262,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): GroupedAllocationConfig = apply { + fun validate(): GroupedWithProratedMinimumConfig = apply { if (!validated) { validated = true } @@ -34486,8 +36280,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { - additionalProperties(groupedAllocationConfig.additionalProperties) + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + additionalProperties(groupedWithProratedMinimumConfig.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -34505,8 +36301,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) } override fun equals(other: Any?): Boolean { @@ -34514,7 +36310,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupedAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -34527,7 +36323,7 @@ private constructor( } override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) @@ -35177,29 +36973,31 @@ private constructor( companion object { - @JvmField val GROUPED_ALLOCATION = ModelType(JsonField.of("grouped_allocation")) + @JvmField + val GROUPED_WITH_PRORATED_MINIMUM = + ModelType(JsonField.of("grouped_with_prorated_minimum")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - GROUPED_ALLOCATION, + GROUPED_WITH_PRORATED_MINIMUM, } enum class Value { - GROUPED_ALLOCATION, + GROUPED_WITH_PRORATED_MINIMUM, _UNKNOWN, } fun value(): Value = when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION + GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM else -> Value._UNKNOWN } fun known(): Known = when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION + GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -35268,25 +37066,25 @@ private constructor( return true } - return /* spotless:off */ other is GroupedAllocationPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.groupedAllocationConfig == other.groupedAllocationConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimumPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, groupedAllocationConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, groupedWithProratedMinimumConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "GroupedAllocationPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, groupedAllocationConfig=$groupedAllocationConfig, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimumPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GroupedWithProratedMinimumPrice.Builder::class) + @JsonDeserialize(builder = GroupedWithMeteredMinimumPrice.Builder::class) @NoAutoDetect - class GroupedWithProratedMinimumPrice + class GroupedWithMeteredMinimumPrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -35310,7 +37108,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val groupedWithProratedMinimumConfig: JsonField, + private val groupedWithMeteredMinimumConfig: JsonField, private val additionalProperties: Map, ) { @@ -35377,8 +37175,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -35437,15 +37235,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("grouped_with_prorated_minimum_config") + @JsonProperty("grouped_with_metered_minimum_config") @ExcludeMissing - fun _groupedWithProratedMinimumConfig() = groupedWithProratedMinimumConfig + fun _groupedWithMeteredMinimumConfig() = groupedWithMeteredMinimumConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): GroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimumPrice = apply { if (!validated) { metadata().validate() id() @@ -35469,7 +37267,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - groupedWithProratedMinimumConfig().validate() + groupedWithMeteredMinimumConfig().validate() validated = true } } @@ -35507,41 +37305,41 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var groupedWithProratedMinimumConfig: - JsonField = + private var groupedWithMeteredMinimumConfig: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice) = + internal fun from(groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice) = apply { - this.metadata = groupedWithProratedMinimumPrice.metadata - this.id = groupedWithProratedMinimumPrice.id - this.name = groupedWithProratedMinimumPrice.name - this.externalPriceId = groupedWithProratedMinimumPrice.externalPriceId - this.priceType = groupedWithProratedMinimumPrice.priceType - this.modelType = groupedWithProratedMinimumPrice.modelType - this.createdAt = groupedWithProratedMinimumPrice.createdAt - this.cadence = groupedWithProratedMinimumPrice.cadence + this.metadata = groupedWithMeteredMinimumPrice.metadata + this.id = groupedWithMeteredMinimumPrice.id + this.name = groupedWithMeteredMinimumPrice.name + this.externalPriceId = groupedWithMeteredMinimumPrice.externalPriceId + this.priceType = groupedWithMeteredMinimumPrice.priceType + this.modelType = groupedWithMeteredMinimumPrice.modelType + this.createdAt = groupedWithMeteredMinimumPrice.createdAt + this.cadence = groupedWithMeteredMinimumPrice.cadence this.billingCycleConfiguration = - groupedWithProratedMinimumPrice.billingCycleConfiguration + groupedWithMeteredMinimumPrice.billingCycleConfiguration this.invoicingCycleConfiguration = - groupedWithProratedMinimumPrice.invoicingCycleConfiguration - this.billableMetric = groupedWithProratedMinimumPrice.billableMetric - this.fixedPriceQuantity = groupedWithProratedMinimumPrice.fixedPriceQuantity - this.planPhaseOrder = groupedWithProratedMinimumPrice.planPhaseOrder - this.currency = groupedWithProratedMinimumPrice.currency - this.conversionRate = groupedWithProratedMinimumPrice.conversionRate - this.item = groupedWithProratedMinimumPrice.item - this.creditAllocation = groupedWithProratedMinimumPrice.creditAllocation - this.discount = groupedWithProratedMinimumPrice.discount - this.minimum = groupedWithProratedMinimumPrice.minimum - this.minimumAmount = groupedWithProratedMinimumPrice.minimumAmount - this.maximum = groupedWithProratedMinimumPrice.maximum - this.maximumAmount = groupedWithProratedMinimumPrice.maximumAmount - this.groupedWithProratedMinimumConfig = - groupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig - additionalProperties(groupedWithProratedMinimumPrice.additionalProperties) + groupedWithMeteredMinimumPrice.invoicingCycleConfiguration + this.billableMetric = groupedWithMeteredMinimumPrice.billableMetric + this.fixedPriceQuantity = groupedWithMeteredMinimumPrice.fixedPriceQuantity + this.planPhaseOrder = groupedWithMeteredMinimumPrice.planPhaseOrder + this.currency = groupedWithMeteredMinimumPrice.currency + this.conversionRate = groupedWithMeteredMinimumPrice.conversionRate + this.item = groupedWithMeteredMinimumPrice.item + this.creditAllocation = groupedWithMeteredMinimumPrice.creditAllocation + this.discount = groupedWithMeteredMinimumPrice.discount + this.minimum = groupedWithMeteredMinimumPrice.minimum + this.minimumAmount = groupedWithMeteredMinimumPrice.minimumAmount + this.maximum = groupedWithMeteredMinimumPrice.maximum + this.maximumAmount = groupedWithMeteredMinimumPrice.maximumAmount + this.groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig + additionalProperties(groupedWithMeteredMinimumPrice.additionalProperties) } /** @@ -35716,15 +37514,15 @@ private constructor( this.maximumAmount = maximumAmount } - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) - @JsonProperty("grouped_with_prorated_minimum_config") + @JsonProperty("grouped_with_metered_minimum_config") @ExcludeMissing - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: JsonField - ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -35740,8 +37538,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupedWithProratedMinimumPrice = - GroupedWithProratedMinimumPrice( + fun build(): GroupedWithMeteredMinimumPrice = + GroupedWithMeteredMinimumPrice( metadata, id, name, @@ -35764,7 +37562,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - groupedWithProratedMinimumConfig, + groupedWithMeteredMinimumConfig, additionalProperties.toUnmodifiable(), ) } @@ -36216,9 +38014,9 @@ private constructor( "CreditAllocation{currency=$currency, allowsRollover=$allowsRollover, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GroupedWithProratedMinimumConfig.Builder::class) + @JsonDeserialize(builder = GroupedWithMeteredMinimumConfig.Builder::class) @NoAutoDetect - class GroupedWithProratedMinimumConfig + class GroupedWithMeteredMinimumConfig private constructor( private val additionalProperties: Map, ) { @@ -36229,7 +38027,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): GroupedWithProratedMinimumConfig = apply { + fun validate(): GroupedWithMeteredMinimumConfig = apply { if (!validated) { validated = true } @@ -36248,9 +38046,9 @@ private constructor( @JvmSynthetic internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig ) = apply { - additionalProperties(groupedWithProratedMinimumConfig.additionalProperties) + additionalProperties(groupedWithMeteredMinimumConfig.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -36268,8 +38066,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig(additionalProperties.toUnmodifiable()) } override fun equals(other: Any?): Boolean { @@ -36277,7 +38075,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 @@ -36290,7 +38088,7 @@ private constructor( } override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) @@ -36941,30 +38739,30 @@ private constructor( companion object { @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = - ModelType(JsonField.of("grouped_with_prorated_minimum")) + val GROUPED_WITH_METERED_MINIMUM = + ModelType(JsonField.of("grouped_with_metered_minimum")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - GROUPED_WITH_PRORATED_MINIMUM, + GROUPED_WITH_METERED_MINIMUM, } enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, + GROUPED_WITH_METERED_MINIMUM, _UNKNOWN, } fun value(): Value = when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM + GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM else -> Value._UNKNOWN } fun known(): Known = when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM + GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -37033,25 +38831,25 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimumPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimumPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, groupedWithProratedMinimumConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, groupedWithMeteredMinimumConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "GroupedWithProratedMinimumPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GroupedWithMeteredMinimumPrice.Builder::class) + @JsonDeserialize(builder = MatrixWithDisplayNamePrice.Builder::class) @NoAutoDetect - class GroupedWithMeteredMinimumPrice + class MatrixWithDisplayNamePrice private constructor( private val metadata: JsonField, private val id: JsonField, @@ -37075,7 +38873,7 @@ private constructor( private val minimumAmount: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, - private val groupedWithMeteredMinimumConfig: JsonField, + private val matrixWithDisplayNameConfig: JsonField, private val additionalProperties: Map, ) { @@ -37142,8 +38940,8 @@ private constructor( fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -37202,15 +39000,15 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount - @JsonProperty("grouped_with_metered_minimum_config") + @JsonProperty("matrix_with_display_name_config") @ExcludeMissing - fun _groupedWithMeteredMinimumConfig() = groupedWithMeteredMinimumConfig + fun _matrixWithDisplayNameConfig() = matrixWithDisplayNameConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): GroupedWithMeteredMinimumPrice = apply { + fun validate(): MatrixWithDisplayNamePrice = apply { if (!validated) { metadata().validate() id() @@ -37234,7 +39032,7 @@ private constructor( minimumAmount() maximum().map { it.validate() } maximumAmount() - groupedWithMeteredMinimumConfig().validate() + matrixWithDisplayNameConfig().validate() validated = true } } @@ -37272,42 +39070,40 @@ private constructor( private var minimumAmount: JsonField = JsonMissing.of() private var maximum: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() - private var groupedWithMeteredMinimumConfig: - JsonField = + private var matrixWithDisplayNameConfig: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice) = - apply { - this.metadata = groupedWithMeteredMinimumPrice.metadata - this.id = groupedWithMeteredMinimumPrice.id - this.name = groupedWithMeteredMinimumPrice.name - this.externalPriceId = groupedWithMeteredMinimumPrice.externalPriceId - this.priceType = groupedWithMeteredMinimumPrice.priceType - this.modelType = groupedWithMeteredMinimumPrice.modelType - this.createdAt = groupedWithMeteredMinimumPrice.createdAt - this.cadence = groupedWithMeteredMinimumPrice.cadence - this.billingCycleConfiguration = - groupedWithMeteredMinimumPrice.billingCycleConfiguration - this.invoicingCycleConfiguration = - groupedWithMeteredMinimumPrice.invoicingCycleConfiguration - this.billableMetric = groupedWithMeteredMinimumPrice.billableMetric - this.fixedPriceQuantity = groupedWithMeteredMinimumPrice.fixedPriceQuantity - this.planPhaseOrder = groupedWithMeteredMinimumPrice.planPhaseOrder - this.currency = groupedWithMeteredMinimumPrice.currency - this.conversionRate = groupedWithMeteredMinimumPrice.conversionRate - this.item = groupedWithMeteredMinimumPrice.item - this.creditAllocation = groupedWithMeteredMinimumPrice.creditAllocation - this.discount = groupedWithMeteredMinimumPrice.discount - this.minimum = groupedWithMeteredMinimumPrice.minimum - this.minimumAmount = groupedWithMeteredMinimumPrice.minimumAmount - this.maximum = groupedWithMeteredMinimumPrice.maximum - this.maximumAmount = groupedWithMeteredMinimumPrice.maximumAmount - this.groupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig - additionalProperties(groupedWithMeteredMinimumPrice.additionalProperties) - } + internal fun from(matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice) = apply { + this.metadata = matrixWithDisplayNamePrice.metadata + this.id = matrixWithDisplayNamePrice.id + this.name = matrixWithDisplayNamePrice.name + this.externalPriceId = matrixWithDisplayNamePrice.externalPriceId + this.priceType = matrixWithDisplayNamePrice.priceType + this.modelType = matrixWithDisplayNamePrice.modelType + this.createdAt = matrixWithDisplayNamePrice.createdAt + this.cadence = matrixWithDisplayNamePrice.cadence + this.billingCycleConfiguration = + matrixWithDisplayNamePrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + matrixWithDisplayNamePrice.invoicingCycleConfiguration + this.billableMetric = matrixWithDisplayNamePrice.billableMetric + this.fixedPriceQuantity = matrixWithDisplayNamePrice.fixedPriceQuantity + this.planPhaseOrder = matrixWithDisplayNamePrice.planPhaseOrder + this.currency = matrixWithDisplayNamePrice.currency + this.conversionRate = matrixWithDisplayNamePrice.conversionRate + this.item = matrixWithDisplayNamePrice.item + this.creditAllocation = matrixWithDisplayNamePrice.creditAllocation + this.discount = matrixWithDisplayNamePrice.discount + this.minimum = matrixWithDisplayNamePrice.minimum + this.minimumAmount = matrixWithDisplayNamePrice.minimumAmount + this.maximum = matrixWithDisplayNamePrice.maximum + this.maximumAmount = matrixWithDisplayNamePrice.maximumAmount + this.matrixWithDisplayNameConfig = + matrixWithDisplayNamePrice.matrixWithDisplayNameConfig + additionalProperties(matrixWithDisplayNamePrice.additionalProperties) + } /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -37481,15 +39277,15 @@ private constructor( this.maximumAmount = maximumAmount } - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) - @JsonProperty("grouped_with_metered_minimum_config") + @JsonProperty("matrix_with_display_name_config") @ExcludeMissing - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: JsonField - ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -37505,8 +39301,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupedWithMeteredMinimumPrice = - GroupedWithMeteredMinimumPrice( + fun build(): MatrixWithDisplayNamePrice = + MatrixWithDisplayNamePrice( metadata, id, name, @@ -37529,7 +39325,7 @@ private constructor( minimumAmount, maximum, maximumAmount, - groupedWithMeteredMinimumConfig, + matrixWithDisplayNameConfig, additionalProperties.toUnmodifiable(), ) } @@ -37981,83 +39777,6 @@ private constructor( "CreditAllocation{currency=$currency, allowsRollover=$allowsRollover, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GroupedWithMeteredMinimumConfig.Builder::class) - @NoAutoDetect - class GroupedWithMeteredMinimumConfig - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GroupedWithMeteredMinimumConfig = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = apply { - additionalProperties(groupedWithMeteredMinimumConfig.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toUnmodifiable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" - } - @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) @NoAutoDetect class InvoicingCycleConfiguration @@ -38333,6 +40052,82 @@ private constructor( "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" } + @JsonDeserialize(builder = MatrixWithDisplayNameConfig.Builder::class) + @NoAutoDetect + class MatrixWithDisplayNameConfig + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = + apply { + additionalProperties(matrixWithDisplayNameConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixWithDisplayNameConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + } + @JsonDeserialize(builder = Maximum.Builder::class) @NoAutoDetect class Maximum @@ -38706,30 +40501,29 @@ private constructor( companion object { @JvmField - val GROUPED_WITH_METERED_MINIMUM = - ModelType(JsonField.of("grouped_with_metered_minimum")) + val MATRIX_WITH_DISPLAY_NAME = ModelType(JsonField.of("matrix_with_display_name")) @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } enum class Known { - GROUPED_WITH_METERED_MINIMUM, + MATRIX_WITH_DISPLAY_NAME, } enum class Value { - GROUPED_WITH_METERED_MINIMUM, + MATRIX_WITH_DISPLAY_NAME, _UNKNOWN, } fun value(): Value = when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME else -> Value._UNKNOWN } fun known(): Known = when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -38798,20 +40592,20 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMeteredMinimumPrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayNamePrice && this.metadata == other.metadata && this.id == other.id && this.name == other.name && this.externalPriceId == other.externalPriceId && this.priceType == other.priceType && this.modelType == other.modelType && this.createdAt == other.createdAt && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.billableMetric == other.billableMetric && this.fixedPriceQuantity == other.fixedPriceQuantity && this.planPhaseOrder == other.planPhaseOrder && this.currency == other.currency && this.conversionRate == other.conversionRate && this.item == other.item && this.creditAllocation == other.creditAllocation && this.discount == other.discount && this.minimum == other.minimum && this.minimumAmount == other.minimumAmount && this.maximum == other.maximum && this.maximumAmount == other.maximumAmount && this.matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, groupedWithMeteredMinimumConfig, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(metadata, id, name, externalPriceId, priceType, modelType, createdAt, cadence, billingCycleConfiguration, invoicingCycleConfiguration, billableMetric, fixedPriceQuantity, planPhaseOrder, currency, conversionRate, item, creditAllocation, discount, minimum, minimumAmount, maximum, maximumAmount, matrixWithDisplayNameConfig, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "GroupedWithMeteredMinimumPrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, additionalProperties=$additionalProperties}" + "MatrixWithDisplayNamePrice{metadata=$metadata, id=$id, name=$name, externalPriceId=$externalPriceId, priceType=$priceType, modelType=$modelType, createdAt=$createdAt, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, billableMetric=$billableMetric, fixedPriceQuantity=$fixedPriceQuantity, planPhaseOrder=$planPhaseOrder, currency=$currency, conversionRate=$conversionRate, item=$item, creditAllocation=$creditAllocation, discount=$discount, minimum=$minimum, minimumAmount=$minimumAmount, maximum=$maximum, maximumAmount=$maximumAmount, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = BulkWithProrationPrice.Builder::class) 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 a0e571754..8079b3f80 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 @@ -53,6 +53,7 @@ constructor( NewFloatingGroupedWithProratedMinimumPrice?, private val newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice?, + private val newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice?, private val newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice?, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, @@ -124,6 +125,9 @@ constructor( Optional = Optional.ofNullable(newFloatingGroupedWithMeteredMinimumPrice) + fun newFloatingMatrixWithDisplayNamePrice(): Optional = + Optional.ofNullable(newFloatingMatrixWithDisplayNamePrice) + fun newFloatingBulkWithProrationPrice(): Optional = Optional.ofNullable(newFloatingBulkWithProrationPrice) @@ -151,6 +155,7 @@ constructor( newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, + newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice, ) } @@ -194,6 +199,8 @@ constructor( private val newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice? = null, + private val newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice? = + null, private val newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice? = null, private val _json: JsonValue? = null, ) { @@ -265,6 +272,10 @@ constructor( Optional = Optional.ofNullable(newFloatingGroupedWithMeteredMinimumPrice) + fun newFloatingMatrixWithDisplayNamePrice(): + Optional = + Optional.ofNullable(newFloatingMatrixWithDisplayNamePrice) + fun newFloatingBulkWithProrationPrice(): Optional = Optional.ofNullable(newFloatingBulkWithProrationPrice) @@ -320,6 +331,9 @@ constructor( fun isNewFloatingGroupedWithMeteredMinimumPrice(): Boolean = newFloatingGroupedWithMeteredMinimumPrice != null + fun isNewFloatingMatrixWithDisplayNamePrice(): Boolean = + newFloatingMatrixWithDisplayNamePrice != null + fun isNewFloatingBulkWithProrationPrice(): Boolean = newFloatingBulkWithProrationPrice != null @@ -396,6 +410,11 @@ constructor( "newFloatingGroupedWithMeteredMinimumPrice" ) + fun asNewFloatingMatrixWithDisplayNamePrice(): NewFloatingMatrixWithDisplayNamePrice = + newFloatingMatrixWithDisplayNamePrice.getOrThrow( + "newFloatingMatrixWithDisplayNamePrice" + ) + fun asNewFloatingBulkWithProrationPrice(): NewFloatingBulkWithProrationPrice = newFloatingBulkWithProrationPrice.getOrThrow("newFloatingBulkWithProrationPrice") @@ -464,6 +483,10 @@ constructor( visitor.visitNewFloatingGroupedWithMeteredMinimumPrice( newFloatingGroupedWithMeteredMinimumPrice ) + newFloatingMatrixWithDisplayNamePrice != null -> + visitor.visitNewFloatingMatrixWithDisplayNamePrice( + newFloatingMatrixWithDisplayNamePrice + ) newFloatingBulkWithProrationPrice != null -> visitor.visitNewFloatingBulkWithProrationPrice( newFloatingBulkWithProrationPrice @@ -477,11 +500,11 @@ constructor( return true } - return /* spotless:off */ other is PriceCreateBody && this.newFloatingUnitPrice == other.newFloatingUnitPrice && this.newFloatingPackagePrice == other.newFloatingPackagePrice && this.newFloatingMatrixPrice == other.newFloatingMatrixPrice && this.newFloatingMatrixWithAllocationPrice == other.newFloatingMatrixWithAllocationPrice && this.newFloatingTieredPrice == other.newFloatingTieredPrice && this.newFloatingTieredBpsPrice == other.newFloatingTieredBpsPrice && this.newFloatingBpsPrice == other.newFloatingBpsPrice && this.newFloatingBulkBpsPrice == other.newFloatingBulkBpsPrice && this.newFloatingBulkPrice == other.newFloatingBulkPrice && this.newFloatingThresholdTotalAmountPrice == other.newFloatingThresholdTotalAmountPrice && this.newFloatingTieredPackagePrice == other.newFloatingTieredPackagePrice && this.newFloatingGroupedTieredPrice == other.newFloatingGroupedTieredPrice && this.newFloatingTieredWithMinimumPrice == other.newFloatingTieredWithMinimumPrice && this.newFloatingPackageWithAllocationPrice == other.newFloatingPackageWithAllocationPrice && this.newFloatingTieredPackageWithMinimumPrice == other.newFloatingTieredPackageWithMinimumPrice && this.newFloatingUnitWithPercentPrice == other.newFloatingUnitWithPercentPrice && this.newFloatingTieredWithProrationPrice == other.newFloatingTieredWithProrationPrice && this.newFloatingUnitWithProrationPrice == other.newFloatingUnitWithProrationPrice && this.newFloatingGroupedAllocationPrice == other.newFloatingGroupedAllocationPrice && this.newFloatingGroupedWithProratedMinimumPrice == other.newFloatingGroupedWithProratedMinimumPrice && this.newFloatingGroupedWithMeteredMinimumPrice == other.newFloatingGroupedWithMeteredMinimumPrice && this.newFloatingBulkWithProrationPrice == other.newFloatingBulkWithProrationPrice /* spotless:on */ + return /* spotless:off */ other is PriceCreateBody && this.newFloatingUnitPrice == other.newFloatingUnitPrice && this.newFloatingPackagePrice == other.newFloatingPackagePrice && this.newFloatingMatrixPrice == other.newFloatingMatrixPrice && this.newFloatingMatrixWithAllocationPrice == other.newFloatingMatrixWithAllocationPrice && this.newFloatingTieredPrice == other.newFloatingTieredPrice && this.newFloatingTieredBpsPrice == other.newFloatingTieredBpsPrice && this.newFloatingBpsPrice == other.newFloatingBpsPrice && this.newFloatingBulkBpsPrice == other.newFloatingBulkBpsPrice && this.newFloatingBulkPrice == other.newFloatingBulkPrice && this.newFloatingThresholdTotalAmountPrice == other.newFloatingThresholdTotalAmountPrice && this.newFloatingTieredPackagePrice == other.newFloatingTieredPackagePrice && this.newFloatingGroupedTieredPrice == other.newFloatingGroupedTieredPrice && this.newFloatingTieredWithMinimumPrice == other.newFloatingTieredWithMinimumPrice && this.newFloatingPackageWithAllocationPrice == other.newFloatingPackageWithAllocationPrice && this.newFloatingTieredPackageWithMinimumPrice == other.newFloatingTieredPackageWithMinimumPrice && this.newFloatingUnitWithPercentPrice == other.newFloatingUnitWithPercentPrice && this.newFloatingTieredWithProrationPrice == other.newFloatingTieredWithProrationPrice && this.newFloatingUnitWithProrationPrice == other.newFloatingUnitWithProrationPrice && this.newFloatingGroupedAllocationPrice == other.newFloatingGroupedAllocationPrice && this.newFloatingGroupedWithProratedMinimumPrice == other.newFloatingGroupedWithProratedMinimumPrice && this.newFloatingGroupedWithMeteredMinimumPrice == other.newFloatingGroupedWithMeteredMinimumPrice && this.newFloatingMatrixWithDisplayNamePrice == other.newFloatingMatrixWithDisplayNamePrice && this.newFloatingBulkWithProrationPrice == other.newFloatingBulkWithProrationPrice /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(newFloatingUnitPrice, newFloatingPackagePrice, newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice, newFloatingTieredBpsPrice, newFloatingBpsPrice, newFloatingBulkBpsPrice, newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice, newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, newFloatingBulkWithProrationPrice) /* spotless:on */ + return /* spotless:off */ Objects.hash(newFloatingUnitPrice, newFloatingPackagePrice, newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice, newFloatingTieredBpsPrice, newFloatingBpsPrice, newFloatingBulkBpsPrice, newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice, newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice) /* spotless:on */ } override fun toString(): String { @@ -528,6 +551,8 @@ constructor( "PriceCreateBody{newFloatingGroupedWithProratedMinimumPrice=$newFloatingGroupedWithProratedMinimumPrice}" newFloatingGroupedWithMeteredMinimumPrice != null -> "PriceCreateBody{newFloatingGroupedWithMeteredMinimumPrice=$newFloatingGroupedWithMeteredMinimumPrice}" + newFloatingMatrixWithDisplayNamePrice != null -> + "PriceCreateBody{newFloatingMatrixWithDisplayNamePrice=$newFloatingMatrixWithDisplayNamePrice}" newFloatingBulkWithProrationPrice != null -> "PriceCreateBody{newFloatingBulkWithProrationPrice=$newFloatingBulkWithProrationPrice}" _json != null -> "PriceCreateBody{_unknown=$_json}" @@ -668,6 +693,14 @@ constructor( newFloatingGroupedWithMeteredMinimumPrice ) + @JvmStatic + fun ofNewFloatingMatrixWithDisplayNamePrice( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) = + PriceCreateBody( + newFloatingMatrixWithDisplayNamePrice = newFloatingMatrixWithDisplayNamePrice + ) + @JvmStatic fun ofNewFloatingBulkWithProrationPrice( newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice @@ -750,6 +783,10 @@ constructor( newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice ): T + fun visitNewFloatingMatrixWithDisplayNamePrice( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ): T + fun visitNewFloatingBulkWithProrationPrice( newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice ): T @@ -928,6 +965,18 @@ constructor( ) } } + "matrix_with_display_name" -> { + tryDeserialize( + node, + jacksonTypeRef() + ) + ?.let { + return PriceCreateBody( + newFloatingMatrixWithDisplayNamePrice = it, + _json = json + ) + } + } "bulk_with_proration" -> { tryDeserialize(node, jacksonTypeRef()) ?.let { @@ -993,6 +1042,8 @@ constructor( 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._json != null -> generator.writeObject(value._json) @@ -1011,15 +1062,15 @@ constructor( return true } - return /* spotless:off */ other is PriceCreateParams && this.newFloatingUnitPrice == other.newFloatingUnitPrice && this.newFloatingPackagePrice == other.newFloatingPackagePrice && this.newFloatingMatrixPrice == other.newFloatingMatrixPrice && this.newFloatingMatrixWithAllocationPrice == other.newFloatingMatrixWithAllocationPrice && this.newFloatingTieredPrice == other.newFloatingTieredPrice && this.newFloatingTieredBpsPrice == other.newFloatingTieredBpsPrice && this.newFloatingBpsPrice == other.newFloatingBpsPrice && this.newFloatingBulkBpsPrice == other.newFloatingBulkBpsPrice && this.newFloatingBulkPrice == other.newFloatingBulkPrice && this.newFloatingThresholdTotalAmountPrice == other.newFloatingThresholdTotalAmountPrice && this.newFloatingTieredPackagePrice == other.newFloatingTieredPackagePrice && this.newFloatingGroupedTieredPrice == other.newFloatingGroupedTieredPrice && this.newFloatingTieredWithMinimumPrice == other.newFloatingTieredWithMinimumPrice && this.newFloatingPackageWithAllocationPrice == other.newFloatingPackageWithAllocationPrice && this.newFloatingTieredPackageWithMinimumPrice == other.newFloatingTieredPackageWithMinimumPrice && this.newFloatingUnitWithPercentPrice == other.newFloatingUnitWithPercentPrice && this.newFloatingTieredWithProrationPrice == other.newFloatingTieredWithProrationPrice && this.newFloatingUnitWithProrationPrice == other.newFloatingUnitWithProrationPrice && this.newFloatingGroupedAllocationPrice == other.newFloatingGroupedAllocationPrice && this.newFloatingGroupedWithProratedMinimumPrice == other.newFloatingGroupedWithProratedMinimumPrice && this.newFloatingGroupedWithMeteredMinimumPrice == other.newFloatingGroupedWithMeteredMinimumPrice && this.newFloatingBulkWithProrationPrice == other.newFloatingBulkWithProrationPrice && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is PriceCreateParams && this.newFloatingUnitPrice == other.newFloatingUnitPrice && this.newFloatingPackagePrice == other.newFloatingPackagePrice && this.newFloatingMatrixPrice == other.newFloatingMatrixPrice && this.newFloatingMatrixWithAllocationPrice == other.newFloatingMatrixWithAllocationPrice && this.newFloatingTieredPrice == other.newFloatingTieredPrice && this.newFloatingTieredBpsPrice == other.newFloatingTieredBpsPrice && this.newFloatingBpsPrice == other.newFloatingBpsPrice && this.newFloatingBulkBpsPrice == other.newFloatingBulkBpsPrice && this.newFloatingBulkPrice == other.newFloatingBulkPrice && this.newFloatingThresholdTotalAmountPrice == other.newFloatingThresholdTotalAmountPrice && this.newFloatingTieredPackagePrice == other.newFloatingTieredPackagePrice && this.newFloatingGroupedTieredPrice == other.newFloatingGroupedTieredPrice && this.newFloatingTieredWithMinimumPrice == other.newFloatingTieredWithMinimumPrice && this.newFloatingPackageWithAllocationPrice == other.newFloatingPackageWithAllocationPrice && this.newFloatingTieredPackageWithMinimumPrice == other.newFloatingTieredPackageWithMinimumPrice && this.newFloatingUnitWithPercentPrice == other.newFloatingUnitWithPercentPrice && this.newFloatingTieredWithProrationPrice == other.newFloatingTieredWithProrationPrice && this.newFloatingUnitWithProrationPrice == other.newFloatingUnitWithProrationPrice && this.newFloatingGroupedAllocationPrice == other.newFloatingGroupedAllocationPrice && this.newFloatingGroupedWithProratedMinimumPrice == other.newFloatingGroupedWithProratedMinimumPrice && this.newFloatingGroupedWithMeteredMinimumPrice == other.newFloatingGroupedWithMeteredMinimumPrice && this.newFloatingMatrixWithDisplayNamePrice == other.newFloatingMatrixWithDisplayNamePrice && this.newFloatingBulkWithProrationPrice == other.newFloatingBulkWithProrationPrice && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(newFloatingUnitPrice, newFloatingPackagePrice, newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice, newFloatingTieredBpsPrice, newFloatingBpsPrice, newFloatingBulkBpsPrice, newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice, newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, newFloatingBulkWithProrationPrice, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(newFloatingUnitPrice, newFloatingPackagePrice, newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice, newFloatingTieredBpsPrice, newFloatingBpsPrice, newFloatingBulkBpsPrice, newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice, newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = - "PriceCreateParams{newFloatingUnitPrice=$newFloatingUnitPrice, newFloatingPackagePrice=$newFloatingPackagePrice, newFloatingMatrixPrice=$newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice=$newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice=$newFloatingTieredPrice, newFloatingTieredBpsPrice=$newFloatingTieredBpsPrice, newFloatingBpsPrice=$newFloatingBpsPrice, newFloatingBulkBpsPrice=$newFloatingBulkBpsPrice, newFloatingBulkPrice=$newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice=$newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice=$newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice=$newFloatingGroupedTieredPrice, newFloatingTieredWithMinimumPrice=$newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice=$newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice=$newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice=$newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice=$newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice=$newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice=$newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice=$newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice=$newFloatingGroupedWithMeteredMinimumPrice, newFloatingBulkWithProrationPrice=$newFloatingBulkWithProrationPrice, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "PriceCreateParams{newFloatingUnitPrice=$newFloatingUnitPrice, newFloatingPackagePrice=$newFloatingPackagePrice, newFloatingMatrixPrice=$newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice=$newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice=$newFloatingTieredPrice, newFloatingTieredBpsPrice=$newFloatingTieredBpsPrice, newFloatingBpsPrice=$newFloatingBpsPrice, newFloatingBulkBpsPrice=$newFloatingBulkBpsPrice, newFloatingBulkPrice=$newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice=$newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice=$newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice=$newFloatingGroupedTieredPrice, newFloatingTieredWithMinimumPrice=$newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice=$newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice=$newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice=$newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice=$newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice=$newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice=$newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice=$newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice=$newFloatingGroupedWithMeteredMinimumPrice, newFloatingMatrixWithDisplayNamePrice=$newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice=$newFloatingBulkWithProrationPrice, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -1061,6 +1112,8 @@ constructor( private var newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice? = null + private var newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice? = + null private var newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice? = null private var additionalQueryParams: MutableMap> = mutableMapOf() private var additionalHeaders: MutableMap> = mutableMapOf() @@ -1098,6 +1151,8 @@ constructor( priceCreateParams.newFloatingGroupedWithProratedMinimumPrice this.newFloatingGroupedWithMeteredMinimumPrice = priceCreateParams.newFloatingGroupedWithMeteredMinimumPrice + this.newFloatingMatrixWithDisplayNamePrice = + priceCreateParams.newFloatingMatrixWithDisplayNamePrice this.newFloatingBulkWithProrationPrice = priceCreateParams.newFloatingBulkWithProrationPrice additionalQueryParams(priceCreateParams.additionalQueryParams) @@ -1126,6 +1181,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1151,6 +1207,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1176,6 +1233,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1203,6 +1261,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1228,6 +1287,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1254,6 +1314,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1279,6 +1340,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1304,6 +1366,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1329,6 +1392,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1356,6 +1420,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1383,6 +1448,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1410,6 +1476,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1437,6 +1504,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1464,6 +1532,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1491,6 +1560,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1518,6 +1588,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1545,6 +1616,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1572,6 +1644,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1599,6 +1672,7 @@ constructor( this.newFloatingGroupedAllocationPrice = newFloatingGroupedAllocationPrice this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1627,6 +1701,7 @@ constructor( this.newFloatingGroupedWithProratedMinimumPrice = newFloatingGroupedWithProratedMinimumPrice this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = null } @@ -1655,6 +1730,35 @@ constructor( this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = newFloatingGroupedWithMeteredMinimumPrice + this.newFloatingMatrixWithDisplayNamePrice = null + this.newFloatingBulkWithProrationPrice = null + } + + fun forNewFloatingMatrixWithDisplayNamePrice( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) = apply { + this.newFloatingUnitPrice = null + this.newFloatingPackagePrice = null + this.newFloatingMatrixPrice = null + this.newFloatingMatrixWithAllocationPrice = null + this.newFloatingTieredPrice = null + this.newFloatingTieredBpsPrice = null + this.newFloatingBpsPrice = null + this.newFloatingBulkBpsPrice = null + this.newFloatingBulkPrice = null + this.newFloatingThresholdTotalAmountPrice = null + this.newFloatingTieredPackagePrice = null + this.newFloatingGroupedTieredPrice = null + this.newFloatingTieredWithMinimumPrice = null + this.newFloatingPackageWithAllocationPrice = null + this.newFloatingTieredPackageWithMinimumPrice = null + this.newFloatingUnitWithPercentPrice = null + this.newFloatingTieredWithProrationPrice = null + this.newFloatingUnitWithProrationPrice = null + this.newFloatingGroupedAllocationPrice = null + this.newFloatingGroupedWithProratedMinimumPrice = null + this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = newFloatingMatrixWithDisplayNamePrice this.newFloatingBulkWithProrationPrice = null } @@ -1682,6 +1786,7 @@ constructor( this.newFloatingGroupedAllocationPrice = null this.newFloatingGroupedWithProratedMinimumPrice = null this.newFloatingGroupedWithMeteredMinimumPrice = null + this.newFloatingMatrixWithDisplayNamePrice = null this.newFloatingBulkWithProrationPrice = newFloatingBulkWithProrationPrice } @@ -1748,6 +1853,7 @@ constructor( newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, + newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice, additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), @@ -20604,6 +20710,867 @@ constructor( "NewFloatingGroupedWithMeteredMinimumPrice{metadata=$metadata, externalPriceId=$externalPriceId, name=$name, billableMetricId=$billableMetricId, itemId=$itemId, billedInAdvance=$billedInAdvance, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, conversionRate=$conversionRate, modelType=$modelType, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, currency=$currency, additionalProperties=$additionalProperties}" } + @JsonDeserialize(builder = NewFloatingMatrixWithDisplayNamePrice.Builder::class) + @NoAutoDetect + class NewFloatingMatrixWithDisplayNamePrice + private constructor( + private val metadata: Metadata?, + private val externalPriceId: String?, + private val name: String?, + private val billableMetricId: String?, + private val itemId: String?, + private val billedInAdvance: Boolean?, + private val fixedPriceQuantity: Double?, + private val invoiceGroupingKey: String?, + private val cadence: Cadence?, + private val billingCycleConfiguration: BillingCycleConfiguration?, + private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, + private val conversionRate: Double?, + private val modelType: ModelType?, + private val matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig?, + private val currency: String?, + private val additionalProperties: Map, + ) { + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") fun metadata(): Metadata? = metadata + + /** An alias for the price. */ + @JsonProperty("external_price_id") fun externalPriceId(): String? = externalPriceId + + /** The name of the price. */ + @JsonProperty("name") fun name(): String? = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") fun billableMetricId(): String? = billableMetricId + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") fun itemId(): String? = itemId + + /** + * If 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") fun billedInAdvance(): Boolean? = billedInAdvance + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") fun fixedPriceQuantity(): Double? = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") fun invoiceGroupingKey(): String? = invoiceGroupingKey + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") fun cadence(): Cadence? = cadence + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + fun billingCycleConfiguration(): BillingCycleConfiguration? = billingCycleConfiguration + + /** + * 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") + fun invoicingCycleConfiguration(): InvoicingCycleConfiguration? = + invoicingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") fun conversionRate(): Double? = conversionRate + + @JsonProperty("model_type") fun modelType(): ModelType? = modelType + + @JsonProperty("matrix_with_display_name_config") + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig? = + matrixWithDisplayNameConfig + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") fun currency(): String? = currency + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: Metadata? = null + private var externalPriceId: String? = null + private var name: String? = null + private var billableMetricId: String? = null + private var itemId: String? = null + private var billedInAdvance: Boolean? = null + private var fixedPriceQuantity: Double? = null + private var invoiceGroupingKey: String? = null + private var cadence: Cadence? = null + private var billingCycleConfiguration: BillingCycleConfiguration? = null + private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null + private var conversionRate: Double? = null + private var modelType: ModelType? = null + private var matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig? = null + private var currency: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) = apply { + this.metadata = newFloatingMatrixWithDisplayNamePrice.metadata + this.externalPriceId = newFloatingMatrixWithDisplayNamePrice.externalPriceId + this.name = newFloatingMatrixWithDisplayNamePrice.name + this.billableMetricId = newFloatingMatrixWithDisplayNamePrice.billableMetricId + this.itemId = newFloatingMatrixWithDisplayNamePrice.itemId + this.billedInAdvance = newFloatingMatrixWithDisplayNamePrice.billedInAdvance + this.fixedPriceQuantity = newFloatingMatrixWithDisplayNamePrice.fixedPriceQuantity + this.invoiceGroupingKey = newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey + this.cadence = newFloatingMatrixWithDisplayNamePrice.cadence + this.billingCycleConfiguration = + newFloatingMatrixWithDisplayNamePrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration + this.conversionRate = newFloatingMatrixWithDisplayNamePrice.conversionRate + this.modelType = newFloatingMatrixWithDisplayNamePrice.modelType + this.matrixWithDisplayNameConfig = + newFloatingMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig + this.currency = newFloatingMatrixWithDisplayNamePrice.currency + additionalProperties(newFloatingMatrixWithDisplayNamePrice.additionalProperties) + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + + /** An alias for the price. */ + @JsonProperty("external_price_id") + fun externalPriceId(externalPriceId: String) = apply { + this.externalPriceId = externalPriceId + } + + /** The name of the price. */ + @JsonProperty("name") fun name(name: String) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + fun billableMetricId(billableMetricId: String) = apply { + this.billableMetricId = billableMetricId + } + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") fun itemId(itemId: String) = apply { this.itemId = itemId } + + /** + * If 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") + fun billedInAdvance(billedInAdvance: Boolean) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + fun fixedPriceQuantity(fixedPriceQuantity: Double) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + fun invoiceGroupingKey(invoiceGroupingKey: String) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + apply { + this.billingCycleConfiguration = billingCycleConfiguration + } + + /** + * 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") + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: InvoicingCycleConfiguration + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + fun conversionRate(conversionRate: Double) = apply { + this.conversionRate = conversionRate + } + + @JsonProperty("model_type") + fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + + @JsonProperty("matrix_with_display_name_config") + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") + fun currency(currency: String) = apply { this.currency = currency } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): NewFloatingMatrixWithDisplayNamePrice = + NewFloatingMatrixWithDisplayNamePrice( + metadata, + externalPriceId, + checkNotNull(name) { "`name` is required but was not set" }, + billableMetricId, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + billedInAdvance, + fixedPriceQuantity, + invoiceGroupingKey, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + billingCycleConfiguration, + invoicingCycleConfiguration, + conversionRate, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(matrixWithDisplayNameConfig) { + "`matrixWithDisplayNameConfig` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + additionalProperties.toUnmodifiable(), + ) + } + + class Cadence + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ANNUAL = Cadence(JsonField.of("annual")) + + @JvmField val SEMI_ANNUAL = Cadence(JsonField.of("semi_annual")) + + @JvmField val MONTHLY = Cadence(JsonField.of("monthly")) + + @JvmField val QUARTERLY = Cadence(JsonField.of("quarterly")) + + @JvmField val ONE_TIME = Cadence(JsonField.of("one_time")) + + @JvmField val CUSTOM = Cadence(JsonField.of("custom")) + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ANNUAL -> 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 known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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 asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = MatrixWithDisplayNameConfig.Builder::class) + @NoAutoDetect + class MatrixWithDisplayNameConfig + private constructor( + private val additionalProperties: Map, + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = + apply { + additionalProperties(matrixWithDisplayNameConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixWithDisplayNameConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + } + + class ModelType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val MATRIX_WITH_DISPLAY_NAME = ModelType(JsonField.of("matrix_with_display_name")) + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + enum class Known { + MATRIX_WITH_DISPLAY_NAME, + } + + enum class Value { + MATRIX_WITH_DISPLAY_NAME, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonDeserialize(builder = BillingCycleConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleConfiguration + private constructor( + private val duration: Long?, + private val durationUnit: DurationUnit?, + private val additionalProperties: Map, + ) { + + /** The duration of the billing period. */ + @JsonProperty("duration") fun duration(): Long? = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") fun durationUnit(): DurationUnit? = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var duration: Long? = null + private var durationUnit: DurationUnit? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { + this.duration = billingCycleConfiguration.duration + this.durationUnit = billingCycleConfiguration.durationUnit + additionalProperties(billingCycleConfiguration.additionalProperties) + } + + /** The duration of the billing period. */ + @JsonProperty("duration") + fun duration(duration: Long) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + fun durationUnit(durationUnit: DurationUnit) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleConfiguration = + BillingCycleConfiguration( + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, + additionalProperties.toUnmodifiable(), + ) + } + + class DurationUnit + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = DurationUnit(JsonField.of("day")) + + @JvmField val MONTH = DurationUnit(JsonField.of("month")) + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleConfiguration && this.duration == other.duration && this.durationUnit == other.durationUnit && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(duration, durationUnit, additionalProperties) /* spotless:on */ + } + return 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. + */ + @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) + @NoAutoDetect + class InvoicingCycleConfiguration + private constructor( + private val duration: Long?, + private val durationUnit: DurationUnit?, + private val additionalProperties: Map, + ) { + + /** The duration of the billing period. */ + @JsonProperty("duration") fun duration(): Long? = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") fun durationUnit(): DurationUnit? = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var duration: Long? = null + private var durationUnit: DurationUnit? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = + apply { + this.duration = invoicingCycleConfiguration.duration + this.durationUnit = invoicingCycleConfiguration.durationUnit + additionalProperties(invoicingCycleConfiguration.additionalProperties) + } + + /** The duration of the billing period. */ + @JsonProperty("duration") + fun duration(duration: Long) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + fun durationUnit(durationUnit: DurationUnit) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InvoicingCycleConfiguration = + InvoicingCycleConfiguration( + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, + additionalProperties.toUnmodifiable(), + ) + } + + class DurationUnit + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = DurationUnit(JsonField.of("day")) + + @JvmField val MONTH = DurationUnit(JsonField.of("month")) + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoicingCycleConfiguration && this.duration == other.duration && this.durationUnit == other.durationUnit && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(duration, durationUnit, additionalProperties) /* spotless:on */ + } + return 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingMatrixWithDisplayNamePrice && this.metadata == other.metadata && this.externalPriceId == other.externalPriceId && this.name == other.name && this.billableMetricId == other.billableMetricId && this.itemId == other.itemId && this.billedInAdvance == other.billedInAdvance && this.fixedPriceQuantity == other.fixedPriceQuantity && this.invoiceGroupingKey == other.invoiceGroupingKey && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.conversionRate == other.conversionRate && this.modelType == other.modelType && this.matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && this.currency == other.currency && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, externalPriceId, name, billableMetricId, itemId, billedInAdvance, fixedPriceQuantity, invoiceGroupingKey, cadence, billingCycleConfiguration, invoicingCycleConfiguration, conversionRate, modelType, matrixWithDisplayNameConfig, currency, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "NewFloatingMatrixWithDisplayNamePrice{metadata=$metadata, externalPriceId=$externalPriceId, name=$name, billableMetricId=$billableMetricId, itemId=$itemId, billedInAdvance=$billedInAdvance, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, conversionRate=$conversionRate, modelType=$modelType, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, currency=$currency, additionalProperties=$additionalProperties}" + } + @JsonDeserialize(builder = NewFloatingBulkWithProrationPrice.Builder::class) @NoAutoDetect class NewFloatingBulkWithProrationPrice 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 e02f7071e..443603b9c 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 @@ -1872,6 +1872,9 @@ constructor( private val newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice? = null, + private val newFloatingMatrixWithDisplayNamePrice: + NewFloatingMatrixWithDisplayNamePrice? = + null, private val newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice? = null, private val _json: JsonValue? = null, @@ -1949,6 +1952,10 @@ constructor( Optional = Optional.ofNullable(newFloatingGroupedWithMeteredMinimumPrice) + fun newFloatingMatrixWithDisplayNamePrice(): + Optional = + Optional.ofNullable(newFloatingMatrixWithDisplayNamePrice) + fun newFloatingBulkWithProrationPrice(): Optional = Optional.ofNullable(newFloatingBulkWithProrationPrice) @@ -2005,6 +2012,9 @@ constructor( fun isNewFloatingGroupedWithMeteredMinimumPrice(): Boolean = newFloatingGroupedWithMeteredMinimumPrice != null + fun isNewFloatingMatrixWithDisplayNamePrice(): Boolean = + newFloatingMatrixWithDisplayNamePrice != null + fun isNewFloatingBulkWithProrationPrice(): Boolean = newFloatingBulkWithProrationPrice != null @@ -2088,6 +2098,11 @@ constructor( "newFloatingGroupedWithMeteredMinimumPrice" ) + fun asNewFloatingMatrixWithDisplayNamePrice(): NewFloatingMatrixWithDisplayNamePrice = + newFloatingMatrixWithDisplayNamePrice.getOrThrow( + "newFloatingMatrixWithDisplayNamePrice" + ) + fun asNewFloatingBulkWithProrationPrice(): NewFloatingBulkWithProrationPrice = newFloatingBulkWithProrationPrice.getOrThrow("newFloatingBulkWithProrationPrice") @@ -2159,6 +2174,10 @@ constructor( visitor.visitNewFloatingGroupedWithMeteredMinimumPrice( newFloatingGroupedWithMeteredMinimumPrice ) + newFloatingMatrixWithDisplayNamePrice != null -> + visitor.visitNewFloatingMatrixWithDisplayNamePrice( + newFloatingMatrixWithDisplayNamePrice + ) newFloatingBulkWithProrationPrice != null -> visitor.visitNewFloatingBulkWithProrationPrice( newFloatingBulkWithProrationPrice @@ -2191,6 +2210,7 @@ constructor( newFloatingGroupedAllocationPrice == null && newFloatingGroupedWithProratedMinimumPrice == null && newFloatingGroupedWithMeteredMinimumPrice == null && + newFloatingMatrixWithDisplayNamePrice == null && newFloatingBulkWithProrationPrice == null ) { throw OrbInvalidDataException("Unknown Price: $_json") @@ -2216,6 +2236,7 @@ constructor( newFloatingGroupedAllocationPrice?.validate() newFloatingGroupedWithProratedMinimumPrice?.validate() newFloatingGroupedWithMeteredMinimumPrice?.validate() + newFloatingMatrixWithDisplayNamePrice?.validate() newFloatingBulkWithProrationPrice?.validate() validated = true } @@ -2226,11 +2247,11 @@ constructor( return true } - return /* spotless:off */ other is Price && this.newFloatingUnitPrice == other.newFloatingUnitPrice && this.newFloatingPackagePrice == other.newFloatingPackagePrice && this.newFloatingMatrixPrice == other.newFloatingMatrixPrice && this.newFloatingMatrixWithAllocationPrice == other.newFloatingMatrixWithAllocationPrice && this.newFloatingTieredPrice == other.newFloatingTieredPrice && this.newFloatingTieredBpsPrice == other.newFloatingTieredBpsPrice && this.newFloatingBpsPrice == other.newFloatingBpsPrice && this.newFloatingBulkBpsPrice == other.newFloatingBulkBpsPrice && this.newFloatingBulkPrice == other.newFloatingBulkPrice && this.newFloatingThresholdTotalAmountPrice == other.newFloatingThresholdTotalAmountPrice && this.newFloatingTieredPackagePrice == other.newFloatingTieredPackagePrice && this.newFloatingGroupedTieredPrice == other.newFloatingGroupedTieredPrice && this.newFloatingTieredWithMinimumPrice == other.newFloatingTieredWithMinimumPrice && this.newFloatingPackageWithAllocationPrice == other.newFloatingPackageWithAllocationPrice && this.newFloatingTieredPackageWithMinimumPrice == other.newFloatingTieredPackageWithMinimumPrice && this.newFloatingUnitWithPercentPrice == other.newFloatingUnitWithPercentPrice && this.newFloatingTieredWithProrationPrice == other.newFloatingTieredWithProrationPrice && this.newFloatingUnitWithProrationPrice == other.newFloatingUnitWithProrationPrice && this.newFloatingGroupedAllocationPrice == other.newFloatingGroupedAllocationPrice && this.newFloatingGroupedWithProratedMinimumPrice == other.newFloatingGroupedWithProratedMinimumPrice && this.newFloatingGroupedWithMeteredMinimumPrice == other.newFloatingGroupedWithMeteredMinimumPrice && this.newFloatingBulkWithProrationPrice == other.newFloatingBulkWithProrationPrice /* spotless:on */ + return /* spotless:off */ other is Price && this.newFloatingUnitPrice == other.newFloatingUnitPrice && this.newFloatingPackagePrice == other.newFloatingPackagePrice && this.newFloatingMatrixPrice == other.newFloatingMatrixPrice && this.newFloatingMatrixWithAllocationPrice == other.newFloatingMatrixWithAllocationPrice && this.newFloatingTieredPrice == other.newFloatingTieredPrice && this.newFloatingTieredBpsPrice == other.newFloatingTieredBpsPrice && this.newFloatingBpsPrice == other.newFloatingBpsPrice && this.newFloatingBulkBpsPrice == other.newFloatingBulkBpsPrice && this.newFloatingBulkPrice == other.newFloatingBulkPrice && this.newFloatingThresholdTotalAmountPrice == other.newFloatingThresholdTotalAmountPrice && this.newFloatingTieredPackagePrice == other.newFloatingTieredPackagePrice && this.newFloatingGroupedTieredPrice == other.newFloatingGroupedTieredPrice && this.newFloatingTieredWithMinimumPrice == other.newFloatingTieredWithMinimumPrice && this.newFloatingPackageWithAllocationPrice == other.newFloatingPackageWithAllocationPrice && this.newFloatingTieredPackageWithMinimumPrice == other.newFloatingTieredPackageWithMinimumPrice && this.newFloatingUnitWithPercentPrice == other.newFloatingUnitWithPercentPrice && this.newFloatingTieredWithProrationPrice == other.newFloatingTieredWithProrationPrice && this.newFloatingUnitWithProrationPrice == other.newFloatingUnitWithProrationPrice && this.newFloatingGroupedAllocationPrice == other.newFloatingGroupedAllocationPrice && this.newFloatingGroupedWithProratedMinimumPrice == other.newFloatingGroupedWithProratedMinimumPrice && this.newFloatingGroupedWithMeteredMinimumPrice == other.newFloatingGroupedWithMeteredMinimumPrice && this.newFloatingMatrixWithDisplayNamePrice == other.newFloatingMatrixWithDisplayNamePrice && this.newFloatingBulkWithProrationPrice == other.newFloatingBulkWithProrationPrice /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(newFloatingUnitPrice, newFloatingPackagePrice, newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice, newFloatingTieredBpsPrice, newFloatingBpsPrice, newFloatingBulkBpsPrice, newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice, newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, newFloatingBulkWithProrationPrice) /* spotless:on */ + return /* spotless:off */ Objects.hash(newFloatingUnitPrice, newFloatingPackagePrice, newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice, newFloatingTieredBpsPrice, newFloatingBpsPrice, newFloatingBulkBpsPrice, newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice, newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice) /* spotless:on */ } override fun toString(): String { @@ -2276,6 +2297,8 @@ constructor( "Price{newFloatingGroupedWithProratedMinimumPrice=$newFloatingGroupedWithProratedMinimumPrice}" newFloatingGroupedWithMeteredMinimumPrice != null -> "Price{newFloatingGroupedWithMeteredMinimumPrice=$newFloatingGroupedWithMeteredMinimumPrice}" + newFloatingMatrixWithDisplayNamePrice != null -> + "Price{newFloatingMatrixWithDisplayNamePrice=$newFloatingMatrixWithDisplayNamePrice}" newFloatingBulkWithProrationPrice != null -> "Price{newFloatingBulkWithProrationPrice=$newFloatingBulkWithProrationPrice}" _json != null -> "Price{_unknown=$_json}" @@ -2408,6 +2431,15 @@ constructor( newFloatingGroupedWithMeteredMinimumPrice ) + @JvmStatic + fun ofNewFloatingMatrixWithDisplayNamePrice( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) = + Price( + newFloatingMatrixWithDisplayNamePrice = + newFloatingMatrixWithDisplayNamePrice + ) + @JvmStatic fun ofNewFloatingBulkWithProrationPrice( newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice @@ -2493,6 +2525,10 @@ constructor( NewFloatingGroupedWithMeteredMinimumPrice ): T + fun visitNewFloatingMatrixWithDisplayNamePrice( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ): T + fun visitNewFloatingBulkWithProrationPrice( newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice ): T @@ -2741,6 +2777,20 @@ constructor( ) } } + "matrix_with_display_name" -> { + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } + ?.let { + return Price( + newFloatingMatrixWithDisplayNamePrice = it, + _json = json + ) + } + } "bulk_with_proration" -> { tryDeserialize( node, @@ -2811,6 +2861,8 @@ constructor( 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._json != null -> generator.writeObject(value._json) @@ -28687,6 +28739,1183 @@ constructor( "NewFloatingGroupedWithMeteredMinimumPrice{metadata=$metadata, externalPriceId=$externalPriceId, name=$name, billableMetricId=$billableMetricId, itemId=$itemId, billedInAdvance=$billedInAdvance, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, conversionRate=$conversionRate, modelType=$modelType, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, currency=$currency, additionalProperties=$additionalProperties}" } + @JsonDeserialize(builder = NewFloatingMatrixWithDisplayNamePrice.Builder::class) + @NoAutoDetect + class NewFloatingMatrixWithDisplayNamePrice + private constructor( + private val metadata: JsonField, + private val externalPriceId: JsonField, + private val name: JsonField, + private val billableMetricId: JsonField, + private val itemId: JsonField, + private val billedInAdvance: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val cadence: JsonField, + private val billingCycleConfiguration: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val modelType: JsonField, + private val matrixWithDisplayNameConfig: JsonField, + private val currency: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** 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")) + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * If the Price 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, 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")) + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId() = externalPriceId + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name() = 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() = billableMetricId + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + /** + * If 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() = billedInAdvance + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity() = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey() = invoiceGroupingKey + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration() = billingCycleConfiguration + + /** + * 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() = invoicingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate() = conversionRate + + @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig() = matrixWithDisplayNameConfig + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { + if (!validated) { + metadata().map { it.validate() } + externalPriceId() + name() + billableMetricId() + itemId() + billedInAdvance() + fixedPriceQuantity() + invoiceGroupingKey() + cadence() + billingCycleConfiguration().map { it.validate() } + invoicingCycleConfiguration().map { it.validate() } + conversionRate() + modelType() + matrixWithDisplayNameConfig().validate() + currency() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var billableMetricId: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var cadence: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var modelType: JsonField = JsonMissing.of() + private var matrixWithDisplayNameConfig: + JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) = apply { + this.metadata = newFloatingMatrixWithDisplayNamePrice.metadata + this.externalPriceId = newFloatingMatrixWithDisplayNamePrice.externalPriceId + this.name = newFloatingMatrixWithDisplayNamePrice.name + this.billableMetricId = + newFloatingMatrixWithDisplayNamePrice.billableMetricId + this.itemId = newFloatingMatrixWithDisplayNamePrice.itemId + this.billedInAdvance = newFloatingMatrixWithDisplayNamePrice.billedInAdvance + this.fixedPriceQuantity = + newFloatingMatrixWithDisplayNamePrice.fixedPriceQuantity + this.invoiceGroupingKey = + newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey + this.cadence = newFloatingMatrixWithDisplayNamePrice.cadence + this.billingCycleConfiguration = + newFloatingMatrixWithDisplayNamePrice.billingCycleConfiguration + this.invoicingCycleConfiguration = + newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration + this.conversionRate = newFloatingMatrixWithDisplayNamePrice.conversionRate + this.modelType = newFloatingMatrixWithDisplayNamePrice.modelType + this.matrixWithDisplayNameConfig = + newFloatingMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig + this.currency = newFloatingMatrixWithDisplayNamePrice.currency + additionalProperties( + newFloatingMatrixWithDisplayNamePrice.additionalProperties + ) + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by 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. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String) = + externalPriceId(JsonField.of(externalPriceId)) + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + @JsonProperty("name") + @ExcludeMissing + 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.of(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(JsonField.of(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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String) = + invoiceGroupingKey(JsonField.of(invoiceGroupingKey)) + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfiguration + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: InvoicingCycleConfiguration + ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + + /** + * 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( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(JsonField.of(conversionRate)) + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + @JsonProperty("model_type") + @ExcludeMissing + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + /** 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. */ + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): NewFloatingMatrixWithDisplayNamePrice = + NewFloatingMatrixWithDisplayNamePrice( + metadata, + externalPriceId, + name, + billableMetricId, + itemId, + billedInAdvance, + fixedPriceQuantity, + invoiceGroupingKey, + cadence, + billingCycleConfiguration, + invoicingCycleConfiguration, + conversionRate, + modelType, + matrixWithDisplayNameConfig, + currency, + additionalProperties.toUnmodifiable(), + ) + } + + class Cadence + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ANNUAL = Cadence(JsonField.of("annual")) + + @JvmField val SEMI_ANNUAL = Cadence(JsonField.of("semi_annual")) + + @JvmField val MONTHLY = Cadence(JsonField.of("monthly")) + + @JvmField val QUARTERLY = Cadence(JsonField.of("quarterly")) + + @JvmField val ONE_TIME = Cadence(JsonField.of("one_time")) + + @JvmField val CUSTOM = Cadence(JsonField.of("custom")) + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ANNUAL -> 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 known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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 asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = MatrixWithDisplayNameConfig.Builder::class) + @NoAutoDetect + class MatrixWithDisplayNameConfig + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = apply { + additionalProperties(matrixWithDisplayNameConfig.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixWithDisplayNameConfig && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + } + + class ModelType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val MATRIX_WITH_DISPLAY_NAME = + ModelType(JsonField.of("matrix_with_display_name")) + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + enum class Known { + MATRIX_WITH_DISPLAY_NAME, + } + + enum class Value { + MATRIX_WITH_DISPLAY_NAME, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + @JsonDeserialize(builder = BillingCycleConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleConfiguration + private constructor( + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The duration of the billing period. */ + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit() = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var duration: JsonField = JsonMissing.of() + private var durationUnit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = + apply { + this.duration = billingCycleConfiguration.duration + this.durationUnit = billingCycleConfiguration.durationUnit + additionalProperties(billingCycleConfiguration.additionalProperties) + } + + /** The duration of the billing period. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): BillingCycleConfiguration = + BillingCycleConfiguration( + duration, + durationUnit, + additionalProperties.toUnmodifiable(), + ) + } + + class DurationUnit + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = DurationUnit(JsonField.of("day")) + + @JvmField val MONTH = DurationUnit(JsonField.of("month")) + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> + throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleConfiguration && this.duration == other.duration && this.durationUnit == other.durationUnit && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(duration, durationUnit, additionalProperties) /* spotless:on */ + } + return 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. + */ + @JsonDeserialize(builder = InvoicingCycleConfiguration.Builder::class) + @NoAutoDetect + class InvoicingCycleConfiguration + private constructor( + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The duration of the billing period. */ + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit() = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var duration: JsonField = JsonMissing.of() + private var durationUnit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + invoicingCycleConfiguration: InvoicingCycleConfiguration + ) = apply { + this.duration = invoicingCycleConfiguration.duration + this.durationUnit = invoicingCycleConfiguration.durationUnit + additionalProperties(invoicingCycleConfiguration.additionalProperties) + } + + /** The duration of the billing period. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): InvoicingCycleConfiguration = + InvoicingCycleConfiguration( + duration, + durationUnit, + additionalProperties.toUnmodifiable(), + ) + } + + class DurationUnit + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DurationUnit && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = DurationUnit(JsonField.of("day")) + + @JvmField val MONTH = DurationUnit(JsonField.of("month")) + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> + throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoicingCycleConfiguration && this.duration == other.duration && this.durationUnit == other.durationUnit && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(duration, durationUnit, additionalProperties) /* spotless:on */ + } + return 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingMatrixWithDisplayNamePrice && this.metadata == other.metadata && this.externalPriceId == other.externalPriceId && this.name == other.name && this.billableMetricId == other.billableMetricId && this.itemId == other.itemId && this.billedInAdvance == other.billedInAdvance && this.fixedPriceQuantity == other.fixedPriceQuantity && this.invoiceGroupingKey == other.invoiceGroupingKey && this.cadence == other.cadence && this.billingCycleConfiguration == other.billingCycleConfiguration && this.invoicingCycleConfiguration == other.invoicingCycleConfiguration && this.conversionRate == other.conversionRate && this.modelType == other.modelType && this.matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && this.currency == other.currency && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, externalPriceId, name, billableMetricId, itemId, billedInAdvance, fixedPriceQuantity, invoiceGroupingKey, cadence, billingCycleConfiguration, invoicingCycleConfiguration, conversionRate, modelType, matrixWithDisplayNameConfig, currency, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "NewFloatingMatrixWithDisplayNamePrice{metadata=$metadata, externalPriceId=$externalPriceId, name=$name, billableMetricId=$billableMetricId, itemId=$itemId, billedInAdvance=$billedInAdvance, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, cadence=$cadence, billingCycleConfiguration=$billingCycleConfiguration, invoicingCycleConfiguration=$invoicingCycleConfiguration, conversionRate=$conversionRate, modelType=$modelType, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, currency=$currency, additionalProperties=$additionalProperties}" + } + @JsonDeserialize(builder = NewFloatingBulkWithProrationPrice.Builder::class) @NoAutoDetect class NewFloatingBulkWithProrationPrice From 1ab148544455697718f423e1bde89f39669b53ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:17:26 +0000 Subject: [PATCH 5/6] feat(api): api update (#94) --- .stats.yml | 2 +- .../com/withorb/api/core/ClientOptions.kt | 4 +- .../main/kotlin/com/withorb/api/core/Utils.kt | 28 +- .../kotlin/com/withorb/api/core/Values.kt | 4 +- .../api/core/http/BinaryResponseContent.kt | 16 - .../com/withorb/api/core/http/HttpRequest.kt | 6 +- .../kotlin/com/withorb/api/errors/OrbError.kt | 4 +- .../kotlin/com/withorb/api/models/Alert.kt | 16 +- .../models/AlertCreateForCustomerParams.kt | 16 +- .../AlertCreateForExternalCustomerParams.kt | 16 +- .../AlertCreateForSubscriptionParams.kt | 16 +- .../withorb/api/models/AlertDisableParams.kt | 8 +- .../withorb/api/models/AlertEnableParams.kt | 8 +- .../com/withorb/api/models/AlertListPage.kt | 4 +- .../withorb/api/models/AlertListPageAsync.kt | 4 +- .../com/withorb/api/models/AlertListParams.kt | 8 +- .../withorb/api/models/AlertRetrieveParams.kt | 6 +- .../withorb/api/models/AlertUpdateParams.kt | 16 +- .../com/withorb/api/models/AmountDiscount.kt | 6 +- .../com/withorb/api/models/BillableMetric.kt | 6 +- .../kotlin/com/withorb/api/models/Coupon.kt | 4 +- .../withorb/api/models/CouponArchiveParams.kt | 8 +- .../withorb/api/models/CouponCreateParams.kt | 14 +- .../withorb/api/models/CouponFetchParams.kt | 6 +- .../com/withorb/api/models/CouponListPage.kt | 4 +- .../withorb/api/models/CouponListPageAsync.kt | 4 +- .../withorb/api/models/CouponListParams.kt | 8 +- .../api/models/CouponSubscriptionListPage.kt | 4 +- .../models/CouponSubscriptionListPageAsync.kt | 4 +- .../models/CouponSubscriptionListParams.kt | 8 +- .../com/withorb/api/models/CreditNote.kt | 34 +- .../api/models/CreditNoteFetchParams.kt | 6 +- .../withorb/api/models/CreditNoteListPage.kt | 4 +- .../api/models/CreditNoteListPageAsync.kt | 4 +- .../api/models/CreditNoteListParams.kt | 8 +- .../kotlin/com/withorb/api/models/Customer.kt | 22 +- .../CustomerBalanceTransactionCreateParams.kt | 10 +- ...ustomerBalanceTransactionCreateResponse.kt | 8 +- .../CustomerBalanceTransactionListPage.kt | 4 +- ...CustomerBalanceTransactionListPageAsync.kt | 4 +- .../CustomerBalanceTransactionListParams.kt | 8 +- .../CustomerBalanceTransactionListResponse.kt | 8 +- .../CustomerCostListByExternalIdParams.kt | 8 +- .../CustomerCostListByExternalIdResponse.kt | 12 +- .../api/models/CustomerCostListParams.kt | 8 +- .../api/models/CustomerCostListResponse.kt | 12 +- .../api/models/CustomerCreateParams.kt | 34 +- ...editLedgerCreateEntryByExternalIdParams.kt | 28 +- ...itLedgerCreateEntryByExternalIdResponse.kt | 58 +- .../CustomerCreditLedgerCreateEntryParams.kt | 28 +- ...CustomerCreditLedgerCreateEntryResponse.kt | 58 +- ...ustomerCreditLedgerListByExternalIdPage.kt | 4 +- ...erCreditLedgerListByExternalIdPageAsync.kt | 4 +- ...tomerCreditLedgerListByExternalIdParams.kt | 8 +- ...merCreditLedgerListByExternalIdResponse.kt | 58 +- .../models/CustomerCreditLedgerListPage.kt | 4 +- .../CustomerCreditLedgerListPageAsync.kt | 4 +- .../models/CustomerCreditLedgerListParams.kt | 8 +- .../CustomerCreditLedgerListResponse.kt | 58 +- .../CustomerCreditListByExternalIdPage.kt | 4 +- ...CustomerCreditListByExternalIdPageAsync.kt | 4 +- .../CustomerCreditListByExternalIdParams.kt | 8 +- .../CustomerCreditListByExternalIdResponse.kt | 4 +- .../api/models/CustomerCreditListPage.kt | 4 +- .../api/models/CustomerCreditListPageAsync.kt | 4 +- .../api/models/CustomerCreditListParams.kt | 8 +- .../api/models/CustomerCreditListResponse.kt | 4 +- ...omerCreditTopUpCreateByExternalIdParams.kt | 12 +- ...erCreditTopUpCreateByExternalIdResponse.kt | 6 +- .../models/CustomerCreditTopUpCreateParams.kt | 12 +- .../CustomerCreditTopUpCreateResponse.kt | 6 +- ...omerCreditTopUpDeleteByExternalIdParams.kt | 8 +- .../models/CustomerCreditTopUpDeleteParams.kt | 8 +- ...CustomerCreditTopUpListByExternalIdPage.kt | 4 +- ...merCreditTopUpListByExternalIdPageAsync.kt | 4 +- ...stomerCreditTopUpListByExternalIdParams.kt | 8 +- ...omerCreditTopUpListByExternalIdResponse.kt | 6 +- .../api/models/CustomerCreditTopUpListPage.kt | 4 +- .../CustomerCreditTopUpListPageAsync.kt | 4 +- .../models/CustomerCreditTopUpListParams.kt | 8 +- .../models/CustomerCreditTopUpListResponse.kt | 6 +- .../api/models/CustomerDeleteParams.kt | 8 +- .../models/CustomerFetchByExternalIdParams.kt | 6 +- .../withorb/api/models/CustomerFetchParams.kt | 6 +- .../withorb/api/models/CustomerListPage.kt | 4 +- .../api/models/CustomerListPageAsync.kt | 4 +- .../withorb/api/models/CustomerListParams.kt | 8 +- .../CustomerUpdateByExternalIdParams.kt | 34 +- .../api/models/CustomerUpdateParams.kt | 34 +- .../kotlin/com/withorb/api/models/Discount.kt | 6 +- .../withorb/api/models/EvaluatePriceGroup.kt | 6 +- .../api/models/EventBackfillCloseParams.kt | 8 +- .../api/models/EventBackfillCloseResponse.kt | 4 +- .../api/models/EventBackfillCreateParams.kt | 10 +- .../api/models/EventBackfillCreateResponse.kt | 4 +- .../api/models/EventBackfillFetchParams.kt | 6 +- .../api/models/EventBackfillFetchResponse.kt | 4 +- .../api/models/EventBackfillListPage.kt | 4 +- .../api/models/EventBackfillListPageAsync.kt | 4 +- .../api/models/EventBackfillListParams.kt | 8 +- .../api/models/EventBackfillListResponse.kt | 4 +- .../api/models/EventBackfillRevertParams.kt | 8 +- .../api/models/EventBackfillRevertResponse.kt | 4 +- .../api/models/EventDeprecateParams.kt | 8 +- .../api/models/EventDeprecateResponse.kt | 4 +- .../withorb/api/models/EventIngestParams.kt | 19 +- .../withorb/api/models/EventIngestResponse.kt | 16 +- .../withorb/api/models/EventSearchParams.kt | 15 +- .../withorb/api/models/EventSearchResponse.kt | 9 +- .../withorb/api/models/EventUpdateParams.kt | 10 +- .../withorb/api/models/EventUpdateResponse.kt | 4 +- .../api/models/EventVolumeListParams.kt | 8 +- .../com/withorb/api/models/EventVolumes.kt | 6 +- .../kotlin/com/withorb/api/models/Invoice.kt | 76 +- .../withorb/api/models/InvoiceCreateParams.kt | 21 +- .../withorb/api/models/InvoiceFetchParams.kt | 6 +- .../api/models/InvoiceFetchUpcomingParams.kt | 8 +- .../models/InvoiceFetchUpcomingResponse.kt | 76 +- .../withorb/api/models/InvoiceIssueParams.kt | 10 +- .../api/models/InvoiceLineItemCreateParams.kt | 10 +- .../models/InvoiceLineItemCreateResponse.kt | 36 +- .../com/withorb/api/models/InvoiceListPage.kt | 4 +- .../api/models/InvoiceListPageAsync.kt | 4 +- .../withorb/api/models/InvoiceListParams.kt | 10 +- .../api/models/InvoiceMarkPaidParams.kt | 10 +- .../withorb/api/models/InvoiceUpdateParams.kt | 12 +- .../api/models/InvoiceVoidInvoiceParams.kt | 8 +- .../kotlin/com/withorb/api/models/Item.kt | 8 +- .../withorb/api/models/ItemCreateParams.kt | 10 +- .../com/withorb/api/models/ItemFetchParams.kt | 6 +- .../com/withorb/api/models/ItemListPage.kt | 4 +- .../withorb/api/models/ItemListPageAsync.kt | 4 +- .../com/withorb/api/models/ItemListParams.kt | 8 +- .../withorb/api/models/ItemUpdateParams.kt | 16 +- .../withorb/api/models/MetricCreateParams.kt | 12 +- .../withorb/api/models/MetricFetchParams.kt | 6 +- .../com/withorb/api/models/MetricListPage.kt | 4 +- .../withorb/api/models/MetricListPageAsync.kt | 4 +- .../withorb/api/models/MetricListParams.kt | 8 +- .../withorb/api/models/MetricUpdateParams.kt | 12 +- .../withorb/api/models/PaginationMetadata.kt | 4 +- .../withorb/api/models/PercentageDiscount.kt | 6 +- .../kotlin/com/withorb/api/models/Plan.kt | 34 +- .../withorb/api/models/PlanCreateParams.kt | 241 +- .../models/PlanExternalPlanIdFetchParams.kt | 6 +- .../models/PlanExternalPlanIdUpdateParams.kt | 12 +- .../com/withorb/api/models/PlanFetchParams.kt | 6 +- .../com/withorb/api/models/PlanListPage.kt | 4 +- .../withorb/api/models/PlanListPageAsync.kt | 4 +- .../com/withorb/api/models/PlanListParams.kt | 8 +- .../withorb/api/models/PlanUpdateParams.kt | 12 +- .../kotlin/com/withorb/api/models/Price.kt | 612 +- .../withorb/api/models/PriceCreateParams.kt | 272 +- .../withorb/api/models/PriceEvaluateParams.kt | 14 +- .../api/models/PriceEvaluateResponse.kt | 7 +- .../models/PriceExternalPriceIdFetchParams.kt | 6 +- .../PriceExternalPriceIdUpdateParams.kt | 12 +- .../withorb/api/models/PriceFetchParams.kt | 6 +- .../com/withorb/api/models/PriceListPage.kt | 4 +- .../withorb/api/models/PriceListPageAsync.kt | 4 +- .../com/withorb/api/models/PriceListParams.kt | 8 +- .../withorb/api/models/PriceUpdateParams.kt | 12 +- .../com/withorb/api/models/Subscription.kt | 86 +- .../api/models/SubscriptionCancelParams.kt | 10 +- .../api/models/SubscriptionCancelResponse.kt | 5828 ++++++++++++++++ .../api/models/SubscriptionCreateParams.kt | 502 +- .../api/models/SubscriptionCreateResponse.kt | 5828 ++++++++++++++++ .../models/SubscriptionFetchCostsParams.kt | 8 +- .../models/SubscriptionFetchCostsResponse.kt | 12 +- .../api/models/SubscriptionFetchParams.kt | 6 +- .../models/SubscriptionFetchSchedulePage.kt | 4 +- .../SubscriptionFetchSchedulePageAsync.kt | 4 +- .../models/SubscriptionFetchScheduleParams.kt | 8 +- .../SubscriptionFetchScheduleResponse.kt | 6 +- .../models/SubscriptionFetchUsageParams.kt | 8 +- .../api/models/SubscriptionListPage.kt | 4 +- .../api/models/SubscriptionListPageAsync.kt | 4 +- .../api/models/SubscriptionListParams.kt | 10 +- .../SubscriptionPriceIntervalsParams.kt | 330 +- .../SubscriptionPriceIntervalsResponse.kt | 5830 ++++++++++++++++ .../SubscriptionSchedulePlanChangeParams.kt | 498 +- .../SubscriptionSchedulePlanChangeResponse.kt | 5831 ++++++++++++++++ .../models/SubscriptionTriggerPhaseParams.kt | 10 +- .../SubscriptionTriggerPhaseResponse.kt | 5830 ++++++++++++++++ ...ubscriptionUnscheduleCancellationParams.kt | 8 +- ...scriptionUnscheduleCancellationResponse.kt | 5833 ++++++++++++++++ ...UnscheduleFixedFeeQuantityUpdatesParams.kt | 10 +- ...scheduleFixedFeeQuantityUpdatesResponse.kt | 5846 +++++++++++++++++ ...ptionUnschedulePendingPlanChangesParams.kt | 8 +- ...ionUnschedulePendingPlanChangesResponse.kt | 5841 ++++++++++++++++ ...ubscriptionUpdateFixedFeeQuantityParams.kt | 10 +- ...scriptionUpdateFixedFeeQuantityResponse.kt | 5833 ++++++++++++++++ .../api/models/SubscriptionUpdateParams.kt | 12 +- .../models/SubscriptionUpdateTrialParams.kt | 10 +- .../models/SubscriptionUpdateTrialResponse.kt | 5830 ++++++++++++++++ .../withorb/api/models/SubscriptionUsage.kt | 28 +- .../com/withorb/api/models/Subscriptions.kt | 6 +- .../withorb/api/models/TopLevelPingParams.kt | 6 +- .../api/models/TopLevelPingResponse.kt | 4 +- .../com/withorb/api/models/TrialDiscount.kt | 6 +- .../com/withorb/api/services/Handlers.kt | 186 - .../withorb/api/services/HttpRequestBodies.kt | 114 - .../async/SubscriptionServiceAsync.kt | 30 +- .../async/SubscriptionServiceAsyncImpl.kt | 82 +- .../services/blocking/SubscriptionService.kt | 30 +- .../blocking/SubscriptionServiceImpl.kt | 82 +- .../withorb/api/core/http/SerializerTest.kt | 2 +- .../models/SubscriptionCancelResponseTest.kt | 969 +++ .../models/SubscriptionCreateResponseTest.kt | 969 +++ .../SubscriptionPriceIntervalsResponseTest.kt | 979 +++ ...scriptionSchedulePlanChangeResponseTest.kt | 979 +++ .../SubscriptionTriggerPhaseResponseTest.kt | 975 +++ ...ptionUnscheduleCancellationResponseTest.kt | 987 +++ ...duleFixedFeeQuantityUpdatesResponseTest.kt | 1018 +++ ...nschedulePendingPlanChangesResponseTest.kt | 997 +++ ...ptionUpdateFixedFeeQuantityResponseTest.kt | 987 +++ .../SubscriptionUpdateTrialResponseTest.kt | 974 +++ .../blocking/SubscriptionServiceTest.kt | 60 +- 218 files changed, 70549 insertions(+), 2697 deletions(-) delete mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/core/http/BinaryResponseContent.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt create mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt delete mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/services/Handlers.kt delete mode 100644 orb-java-core/src/main/kotlin/com/withorb/api/services/HttpRequestBodies.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt create mode 100644 orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 08ad8bf9a..f1795d479 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 95 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-98c74703b2dc6ba6057447cdf65179965d7a6cee5e26cb0f019b08f5840fbc0a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-1d8364dbd0b3b481f2d5fc42f06ad6df6c581a1cdba0940c9b85936957e7a363.yml 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 1eac0192b..be5b9786a 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 @@ -164,8 +164,8 @@ private constructor( baseUrl, apiKey!!, webhookSecret, - headers.toUnmodifiable(), - queryParams.toUnmodifiable(), + headers.toImmutable(), + queryParams.toImmutable(), responseValidation, maxRetries, ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt index cf1dea288..f576c2da4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt @@ -4,7 +4,6 @@ package com.withorb.api.core import com.google.common.collect.ImmutableListMultimap import com.google.common.collect.ListMultimap -import com.google.common.collect.Multimaps import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections @@ -13,30 +12,15 @@ internal fun T?.getOrThrow(name: String): T = this ?: throw OrbInvalidDataException("`${name}` is not present") @JvmSynthetic -internal fun List.toUnmodifiable(): List { - if (isEmpty()) { - return Collections.emptyList() - } - - return Collections.unmodifiableList(this) -} +internal fun List.toImmutable(): List = + if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) @JvmSynthetic -internal fun Map.toUnmodifiable(): Map { - if (isEmpty()) { - return Collections.emptyMap() - } - - return Collections.unmodifiableMap(this) -} +internal fun Map.toImmutable(): Map = + if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap()) @JvmSynthetic -internal fun ListMultimap.toUnmodifiable(): ListMultimap { - if (isEmpty()) { - return ImmutableListMultimap.of() - } - - return Multimaps.unmodifiableListMultimap(this) -} +internal fun ListMultimap.toImmutable(): ListMultimap = + ImmutableListMultimap.copyOf(this) internal interface Enum 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 523cc7d20..a00f08226 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 @@ -389,7 +389,7 @@ private constructor( override fun toString() = values.toString() companion object { - @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toUnmodifiable()) + @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) } } @@ -415,7 +415,7 @@ private constructor( companion object { @JsonCreator @JvmStatic - fun of(values: Map) = JsonObject(values.toUnmodifiable()) + fun of(values: Map) = JsonObject(values.toImmutable()) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/BinaryResponseContent.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/BinaryResponseContent.kt deleted file mode 100644 index 34d7e5df4..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/BinaryResponseContent.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.withorb.api.core.http - -import java.io.IOException -import java.io.InputStream -import java.io.OutputStream -import java.lang.AutoCloseable -import java.util.Optional - -interface BinaryResponseContent : AutoCloseable { - - fun contentType(): Optional - - fun body(): InputStream - - @Throws(IOException::class) fun writeTo(outputStream: OutputStream) -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequest.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequest.kt index 4587ae046..b2274d812 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequest.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequest.kt @@ -4,7 +4,7 @@ import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ListMultimap import com.google.common.collect.Multimap import com.google.common.collect.MultimapBuilder -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable class HttpRequest private constructor( @@ -83,8 +83,8 @@ private constructor( HttpRequest( checkNotNull(method) { "`method` is required but was not set" }, url, - pathSegments.toUnmodifiable(), - queryParams.toUnmodifiable(), + pathSegments.toImmutable(), + queryParams.toImmutable(), headers, body, ) 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 9073062ae..b925699b9 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 @@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import java.util.Objects @JsonDeserialize(builder = OrbError.Builder::class) @@ -60,6 +60,6 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrbError = OrbError(additionalProperties.toUnmodifiable()) + fun build(): OrbError = OrbError(additionalProperties.toImmutable()) } } 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 8fc4383b9..99745bd5f 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -269,13 +269,13 @@ private constructor( type, createdAt, enabled, - thresholds.map { it.toUnmodifiable() }, + thresholds.map { it.toImmutable() }, customer, plan, subscription, metric, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -329,7 +329,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Customer = Customer(additionalProperties.toUnmodifiable()) + fun build(): Customer = Customer(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -402,7 +402,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metric = Metric(additionalProperties.toUnmodifiable()) + fun build(): Metric = Metric(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -475,7 +475,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Plan = Plan(additionalProperties.toUnmodifiable()) + fun build(): Plan = Plan(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -548,7 +548,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Subscription = Subscription(additionalProperties.toUnmodifiable()) + fun build(): Subscription = Subscription(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -655,7 +655,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Threshold = Threshold(value, additionalProperties.toUnmodifiable()) + fun build(): Threshold = Threshold(value, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 bb0387c24..bad3201d4 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -132,8 +132,8 @@ constructor( AlertCreateForCustomerBody( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, - thresholds?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + thresholds?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -284,10 +284,10 @@ constructor( checkNotNull(customerId) { "`customerId` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, - if (thresholds.size == 0) null else thresholds.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (thresholds.size == 0) null else thresholds.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -428,7 +428,7 @@ constructor( fun build(): Threshold = Threshold( checkNotNull(value) { "`value` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } 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 845caafcb..59b5c3efd 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -134,8 +134,8 @@ constructor( AlertCreateForExternalCustomerBody( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, - thresholds?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + thresholds?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -292,10 +292,10 @@ constructor( }, checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, - if (thresholds.size == 0) null else thresholds.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (thresholds.size == 0) null else thresholds.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -436,7 +436,7 @@ constructor( fun build(): Threshold = Threshold( checkNotNull(value) { "`value` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } 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 e376e73ae..047e0e127 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -132,10 +132,10 @@ constructor( fun build(): AlertCreateForSubscriptionBody = AlertCreateForSubscriptionBody( checkNotNull(thresholds) { "`thresholds` is required but was not set" } - .toUnmodifiable(), + .toImmutable(), checkNotNull(type) { "`type` is required but was not set" }, metricId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -286,12 +286,12 @@ constructor( AlertCreateForSubscriptionParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, checkNotNull(thresholds) { "`thresholds` is required but was not set" } - .toUnmodifiable(), + .toImmutable(), checkNotNull(type) { "`type` is required but was not set" }, metricId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -357,7 +357,7 @@ constructor( fun build(): Threshold = Threshold( checkNotNull(value) { "`value` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } 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 7119b29f7..bbce3b0d1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -142,9 +142,9 @@ constructor( checkNotNull(alertConfigurationId) { "`alertConfigurationId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 7de928fff..4e56d0396 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -142,9 +142,9 @@ constructor( checkNotNull(alertConfigurationId) { "`alertConfigurationId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 8e503855d..5e927acf7 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.AlertService import java.util.Objects import java.util.Optional @@ -176,7 +176,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 e6a2bacce..bb89307cf 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.AlertServiceAsync import java.util.Objects import java.util.Optional @@ -179,7 +179,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 ab0c3a161..402fd26a5 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.time.format.DateTimeFormatter @@ -64,7 +64,7 @@ constructor( this.limit?.let { params.put("limit", listOf(it.toString())) } this.subscriptionId?.let { params.put("subscription_id", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -204,8 +204,8 @@ constructor( externalCustomerId, limit, subscriptionId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 5da2822db..fc9be5f33 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): AlertRetrieveParams = AlertRetrieveParams( checkNotNull(alertId) { "`alertId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 13b8c4145..1f79eee76 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -96,8 +96,8 @@ constructor( fun build(): AlertUpdateBody = AlertUpdateBody( checkNotNull(thresholds) { "`thresholds` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + .toImmutable(), + additionalProperties.toImmutable() ) } @@ -241,10 +241,10 @@ constructor( "`alertConfigurationId` is required but was not set" }, checkNotNull(thresholds) { "`thresholds` is required but was not set" } - .toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + .toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -310,7 +310,7 @@ constructor( fun build(): Threshold = Threshold( checkNotNull(value) { "`value` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } 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 e5933db18..d34157e80 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -155,10 +155,10 @@ private constructor( fun build(): AmountDiscount = AmountDiscount( discountType, - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 ff86fc4b9..c976fd5c0 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -202,7 +202,7 @@ private constructor( description, status, item, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -260,7 +260,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 81a47882e..2fca1cb67 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 @@ -20,7 +20,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -292,7 +292,7 @@ private constructor( durationInMonths, maxRedemptions, archivedAt, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 d2c3ee5f8..77f537951 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -138,9 +138,9 @@ constructor( fun build(): CouponArchiveParams = CouponArchiveParams( checkNotNull(couponId) { "`couponId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 71776c44f..a2989f915 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -166,7 +166,7 @@ constructor( checkNotNull(redemptionCode) { "`redemptionCode` is required but was not set" }, durationInMonths, maxRedemptions, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -328,9 +328,9 @@ constructor( checkNotNull(redemptionCode) { "`redemptionCode` is required but was not set" }, durationInMonths, maxRedemptions, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -571,7 +571,7 @@ constructor( NewCouponPercentageDiscount( discountType, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -735,7 +735,7 @@ constructor( NewCouponAmountDiscount( discountType, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 c469f83b1..ddaea0984 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): CouponFetchParams = CouponFetchParams( checkNotNull(couponId) { "`couponId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 9ab691751..97a2e9c1c 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.CouponService import java.util.Objects import java.util.Optional @@ -176,7 +176,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 cf64aaa59..57877abda 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.CouponServiceAsync import java.util.Objects import java.util.Optional @@ -179,7 +179,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 7eba8144e..e19034e50 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -34,7 +34,7 @@ constructor( this.redemptionCode?.let { params.put("redemption_code", listOf(it.toString())) } this.showArchived?.let { params.put("show_archived", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -148,8 +148,8 @@ constructor( limit, redemptionCode, showArchived, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 c18d37597..aba2ebd18 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.coupons.SubscriptionService import java.util.Objects import java.util.Optional @@ -180,7 +180,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 4e42e383e..39b8def1a 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import java.util.Objects import java.util.Optional @@ -183,7 +183,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 5043e132f..042385807 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -29,7 +29,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -141,8 +141,8 @@ constructor( checkNotNull(couponId) { "`couponId` is required but was not set" }, cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 d6c58c600..da3b86107 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -382,10 +382,10 @@ private constructor( customer, creditNotePdf, minimumAmountRefunded, - discounts.map { it.toUnmodifiable() }, + discounts.map { it.toImmutable() }, maximumAmountAdjustment, - lineItems.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + lineItems.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -476,7 +476,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -688,9 +688,9 @@ private constructor( subtotal, amount, quantity, - discounts.map { it.toUnmodifiable() }, - taxAmounts.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + discounts.map { it.toImmutable() }, + taxAmounts.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -815,7 +815,7 @@ private constructor( taxRateDescription, taxRatePercentage, amount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1017,8 +1017,8 @@ private constructor( amountDiscount, amountApplied, reason, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1260,8 +1260,8 @@ private constructor( percentageDiscount, amountApplied, reason, - appliesToPrices.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPrices.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1398,7 +1398,7 @@ private constructor( AppliesToPrice( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1708,8 +1708,8 @@ private constructor( percentageDiscount, amountApplied, reason, - appliesToPrices.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPrices.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1846,7 +1846,7 @@ private constructor( AppliesToPrice( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 751c2be20..c36dcc548 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): CreditNoteFetchParams = CreditNoteFetchParams( checkNotNull(creditNoteId) { "`creditNoteId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 97f1e0391..08326a847 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.CreditNoteService import java.util.Objects import java.util.Optional @@ -180,7 +180,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 f4050073c..df7b533dd 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.CreditNoteServiceAsync import java.util.Objects import java.util.Optional @@ -183,7 +183,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 df7fb520c..c55641f93 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -26,7 +26,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -126,8 +126,8 @@ constructor( CreditNoteListParams( cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 139fc941d..2a6eb8306 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -990,11 +990,11 @@ private constructor( autoCollection, exemptFromAutomatedTax, emailDelivery, - additionalEmails.map { it.toUnmodifiable() }, + additionalEmails.map { it.toImmutable() }, portalUrl, accountingSyncConfiguration, reportingConfiguration, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1140,7 +1140,7 @@ private constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1219,7 +1219,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1459,7 +1459,7 @@ private constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1686,7 +1686,7 @@ private constructor( country, type, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2782,8 +2782,8 @@ private constructor( fun build(): AccountingSyncConfiguration = AccountingSyncConfiguration( excluded, - accountingProviders.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + accountingProviders.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -2878,7 +2878,7 @@ private constructor( AccountingProvider( providerType, externalProviderId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3045,7 +3045,7 @@ private constructor( } fun build(): ReportingConfiguration = - ReportingConfiguration(exempt, additionalProperties.toUnmodifiable()) + ReportingConfiguration(exempt, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 529e22202..907f01313 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -130,7 +130,7 @@ constructor( checkNotNull(amount) { "`amount` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, description, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -278,9 +278,9 @@ constructor( checkNotNull(amount) { "`amount` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt index 51ea1a2ab..6c45b5235 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -273,7 +273,7 @@ private constructor( invoice, type, creditNote, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -437,7 +437,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): CreditNote = CreditNote(id, additionalProperties.toUnmodifiable()) + fun build(): CreditNote = CreditNote(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -527,7 +527,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Invoice = Invoice(id, additionalProperties.toUnmodifiable()) + fun build(): Invoice = Invoice(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 84cc3f734..73ba5f8f8 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.customers.BalanceTransactionService import java.util.Objects import java.util.Optional @@ -185,7 +185,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 9df126cd2..58ff478f6 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.customers.BalanceTransactionServiceAsync import java.util.Objects import java.util.Optional @@ -188,7 +188,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 dbe94604e..929b42e4c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.time.format.DateTimeFormatter @@ -67,7 +67,7 @@ constructor( ) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -209,8 +209,8 @@ constructor( operationTimeGte, operationTimeLt, operationTimeLte, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt index 79d7af15f..cdb7483a1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -273,7 +273,7 @@ private constructor( invoice, type, creditNote, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -437,7 +437,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): CreditNote = CreditNote(id, additionalProperties.toUnmodifiable()) + fun build(): CreditNote = CreditNote(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -527,7 +527,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Invoice = Invoice(id, additionalProperties.toUnmodifiable()) + fun build(): Invoice = Invoice(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 2699433fa..f0c33d349 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -48,7 +48,7 @@ constructor( } this.viewMode?.let { params.put("view_mode", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -180,8 +180,8 @@ constructor( timeframeEnd, timeframeStart, viewMode, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt index bd63a3c62..c8dfb49b7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -83,8 +83,8 @@ private constructor( fun build(): CustomerCostListByExternalIdResponse = CustomerCostListByExternalIdResponse( - data.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + data.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -230,8 +230,8 @@ private constructor( total, timeframeStart, timeframeEnd, - perPriceCosts.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + perPriceCosts.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1283,7 +1283,7 @@ private constructor( subtotal, total, price, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 9d54810e4..7525c1d64 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -48,7 +48,7 @@ constructor( } this.viewMode?.let { params.put("view_mode", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -175,8 +175,8 @@ constructor( timeframeEnd, timeframeStart, viewMode, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt index a9c5fba81..74e497635 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -81,8 +81,8 @@ private constructor( fun build(): CustomerCostListResponse = CustomerCostListResponse( - data.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + data.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -228,8 +228,8 @@ private constructor( total, timeframeStart, timeframeEnd, - perPriceCosts.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + perPriceCosts.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1281,7 +1281,7 @@ private constructor( subtotal, total, price, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 a4a3418dc..2cb872a77 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -615,7 +615,7 @@ constructor( checkNotNull(email) { "`email` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, accountingSyncConfiguration, - additionalEmails?.toUnmodifiable(), + additionalEmails?.toImmutable(), autoCollection, billingAddress, currency, @@ -629,7 +629,7 @@ constructor( taxConfiguration, taxId, timezone, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1011,7 +1011,7 @@ constructor( checkNotNull(email) { "`email` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, accountingSyncConfiguration, - if (additionalEmails.size == 0) null else additionalEmails.toUnmodifiable(), + if (additionalEmails.size == 0) null else additionalEmails.toImmutable(), autoCollection, billingAddress, currency, @@ -1025,9 +1025,9 @@ constructor( taxConfiguration, taxId, timezone, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -1094,8 +1094,8 @@ constructor( fun build(): AccountingSyncConfiguration = AccountingSyncConfiguration( excluded, - accountingProviders?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + accountingProviders?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -1166,7 +1166,7 @@ constructor( checkNotNull(externalProviderId) { "`externalProviderId` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1304,7 +1304,7 @@ constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1375,7 +1375,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1524,7 +1524,7 @@ constructor( fun build(): ReportingConfiguration = ReportingConfiguration( checkNotNull(exempt) { "`exempt` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -1641,7 +1641,7 @@ constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1920,7 +1920,7 @@ constructor( taxExempt, taxProvider, taxExemptionCode, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2080,7 +2080,7 @@ constructor( NewTaxJarConfiguration( taxExempt, taxProvider, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2331,7 +2331,7 @@ constructor( checkNotNull(country) { "`country` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, checkNotNull(value) { "`value` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 cc3885046..1e17d03a4 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 @@ -21,7 +21,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.LocalDate @@ -614,8 +614,8 @@ constructor( addExpirationChangeCreditLedgerEntryRequestParams, addVoidCreditLedgerEntryRequestParams, addAmendmentCreditLedgerEntryRequestParams, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } @@ -817,7 +817,7 @@ constructor( effectiveDate, perUnitCostBasis, invoiceSettings, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -990,7 +990,7 @@ constructor( checkNotNull(netTerms) { "`netTerms` is required but was not set" }, memo, requireSuccessfulPayment, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1062,7 +1062,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1234,7 +1234,7 @@ constructor( description, checkNotNull(entryType) { "`entryType` is required but was not set" }, checkNotNull(amount) { "`amount` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1336,7 +1336,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1558,7 +1558,7 @@ constructor( checkNotNull(targetExpiryDate) { "`targetExpiryDate` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1660,7 +1660,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1851,7 +1851,7 @@ constructor( checkNotNull(blockId) { "`blockId` is required but was not set" }, voidReason, checkNotNull(amount) { "`amount` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1953,7 +1953,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2187,7 +2187,7 @@ constructor( checkNotNull(entryType) { "`entryType` is required but was not set" }, checkNotNull(amount) { "`amount` is required but was not set" }, checkNotNull(blockId) { "`blockId` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2289,7 +2289,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt index 4ab6a5e8a..e40106a06 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -659,7 +659,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -769,7 +769,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -882,7 +882,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1070,7 +1070,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1445,7 +1445,7 @@ private constructor( priceId, eventId, invoiceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1555,7 +1555,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1668,7 +1668,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1856,7 +1856,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2207,7 +2207,7 @@ private constructor( creditBlock, entryType, newBlockExpiryDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2317,7 +2317,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2430,7 +2430,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2618,7 +2618,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2948,7 +2948,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3058,7 +3058,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3171,7 +3171,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3359,7 +3359,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -3720,7 +3720,7 @@ private constructor( entryType, voidReason, voidAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3830,7 +3830,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3943,7 +3943,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4131,7 +4131,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4513,7 +4513,7 @@ private constructor( newBlockExpiryDate, voidReason, voidAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4623,7 +4623,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4736,7 +4736,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4924,7 +4924,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5254,7 +5254,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5364,7 +5364,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5477,7 +5477,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5665,7 +5665,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 94a166423..c92c0b0de 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 @@ -21,7 +21,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.LocalDate @@ -595,8 +595,8 @@ constructor( addExpirationChangeCreditLedgerEntryRequestParams, addVoidCreditLedgerEntryRequestParams, addAmendmentCreditLedgerEntryRequestParams, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } @@ -798,7 +798,7 @@ constructor( effectiveDate, perUnitCostBasis, invoiceSettings, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -971,7 +971,7 @@ constructor( checkNotNull(netTerms) { "`netTerms` is required but was not set" }, memo, requireSuccessfulPayment, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1043,7 +1043,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1215,7 +1215,7 @@ constructor( description, checkNotNull(entryType) { "`entryType` is required but was not set" }, checkNotNull(amount) { "`amount` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1317,7 +1317,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1539,7 +1539,7 @@ constructor( checkNotNull(targetExpiryDate) { "`targetExpiryDate` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1641,7 +1641,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1832,7 +1832,7 @@ constructor( checkNotNull(blockId) { "`blockId` is required but was not set" }, voidReason, checkNotNull(amount) { "`amount` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1934,7 +1934,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2168,7 +2168,7 @@ constructor( checkNotNull(entryType) { "`entryType` is required but was not set" }, checkNotNull(amount) { "`amount` is required but was not set" }, checkNotNull(blockId) { "`blockId` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2270,7 +2270,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt index be32b7d2d..755e4b4fc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -646,7 +646,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -756,7 +756,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -869,7 +869,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1057,7 +1057,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1432,7 +1432,7 @@ private constructor( priceId, eventId, invoiceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1542,7 +1542,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1655,7 +1655,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1843,7 +1843,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2194,7 +2194,7 @@ private constructor( creditBlock, entryType, newBlockExpiryDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2304,7 +2304,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2417,7 +2417,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2605,7 +2605,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2935,7 +2935,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3045,7 +3045,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3158,7 +3158,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3346,7 +3346,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -3707,7 +3707,7 @@ private constructor( entryType, voidReason, voidAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3817,7 +3817,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3930,7 +3930,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4118,7 +4118,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4500,7 +4500,7 @@ private constructor( newBlockExpiryDate, voidReason, voidAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4610,7 +4610,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4723,7 +4723,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4911,7 +4911,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5241,7 +5241,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5351,7 +5351,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5464,7 +5464,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5652,7 +5652,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 6a1df394b..bf92829c9 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.customers.credits.LedgerService import java.util.Objects import java.util.Optional @@ -186,7 +186,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 9c0b553c7..92574fbf1 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import java.util.Objects import java.util.Optional @@ -189,7 +189,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 97e38f001..abb5d3c62 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -76,7 +76,7 @@ constructor( this.limit?.let { params.put("limit", listOf(it.toString())) } this.minimumAmount?.let { params.put("minimum_amount", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -235,8 +235,8 @@ constructor( entryType, limit, minimumAmount, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt index b10272301..f9f7dfb2c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -657,7 +657,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -767,7 +767,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -880,7 +880,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1068,7 +1068,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1443,7 +1443,7 @@ private constructor( priceId, eventId, invoiceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1553,7 +1553,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1666,7 +1666,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1854,7 +1854,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2205,7 +2205,7 @@ private constructor( creditBlock, entryType, newBlockExpiryDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2315,7 +2315,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2428,7 +2428,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2616,7 +2616,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2946,7 +2946,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3056,7 +3056,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3169,7 +3169,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3357,7 +3357,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -3718,7 +3718,7 @@ private constructor( entryType, voidReason, voidAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3828,7 +3828,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3941,7 +3941,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4129,7 +4129,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4511,7 +4511,7 @@ private constructor( newBlockExpiryDate, voidReason, voidAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4621,7 +4621,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4734,7 +4734,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4922,7 +4922,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5252,7 +5252,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5362,7 +5362,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5475,7 +5475,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5663,7 +5663,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 8bfedaa36..65bd04e28 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.customers.credits.LedgerService import java.util.Objects import java.util.Optional @@ -183,7 +183,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 b8ff27149..159e17f7b 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import java.util.Objects import java.util.Optional @@ -186,7 +186,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 8d36ee238..948f463d8 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -76,7 +76,7 @@ constructor( this.limit?.let { params.put("limit", listOf(it.toString())) } this.minimumAmount?.let { params.put("minimum_amount", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -229,8 +229,8 @@ constructor( entryType, limit, minimumAmount, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt index 8885df9ed..3e2239d8b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -637,7 +637,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -747,7 +747,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -860,7 +860,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1048,7 +1048,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1423,7 +1423,7 @@ private constructor( priceId, eventId, invoiceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1533,7 +1533,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1646,7 +1646,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1834,7 +1834,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2185,7 +2185,7 @@ private constructor( creditBlock, entryType, newBlockExpiryDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2295,7 +2295,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2408,7 +2408,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2596,7 +2596,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2926,7 +2926,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3036,7 +3036,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3149,7 +3149,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3337,7 +3337,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -3698,7 +3698,7 @@ private constructor( entryType, voidReason, voidAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3808,7 +3808,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3921,7 +3921,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4109,7 +4109,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4491,7 +4491,7 @@ private constructor( newBlockExpiryDate, voidReason, voidAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4601,7 +4601,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4714,7 +4714,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4902,7 +4902,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5232,7 +5232,7 @@ private constructor( description, creditBlock, entryType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5342,7 +5342,7 @@ private constructor( id, expiryDate, perUnitCostBasis, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5455,7 +5455,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5643,7 +5643,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 cf5ee1f64..f0f5a6839 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.customers.CreditService import java.util.Objects import java.util.Optional @@ -185,7 +185,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 77e6f061c..c4293936e 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.Objects import java.util.Optional @@ -188,7 +188,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 2582c35bc..ff2149f4a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -37,7 +37,7 @@ constructor( this.includeAllBlocks?.let { params.put("include_all_blocks", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -169,8 +169,8 @@ constructor( cursor, includeAllBlocks, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index f43aab2a9..9edcf2d17 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -193,7 +193,7 @@ private constructor( perUnitCostBasis, status, maximumInitialBalance, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 fa393168c..a9ca30355 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.customers.CreditService import java.util.Objects import java.util.Optional @@ -181,7 +181,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 90ac1e874..93306d523 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.Objects import java.util.Optional @@ -184,7 +184,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 98fab5fa3..e709d08f0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -37,7 +37,7 @@ constructor( this.includeAllBlocks?.let { params.put("include_all_blocks", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -163,8 +163,8 @@ constructor( cursor, includeAllBlocks, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index adafec149..83d50ba15 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -190,7 +190,7 @@ private constructor( perUnitCostBasis, status, maximumInitialBalance, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 5b0d15a84..e0ab2961a 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -224,7 +224,7 @@ constructor( checkNotNull(threshold) { "`threshold` is required but was not set" }, expiresAfter, expiresAfterUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -417,9 +417,9 @@ constructor( checkNotNull(threshold) { "`threshold` is required but was not set" }, expiresAfter, expiresAfterUnit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -533,7 +533,7 @@ constructor( checkNotNull(netTerms) { "`netTerms` is required but was not set" }, memo, requireSuccessfulPayment, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt index 3275667eb..d8395ee1b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -265,7 +265,7 @@ private constructor( invoiceSettings, expiresAfter, expiresAfterUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -442,7 +442,7 @@ private constructor( netTerms, memo, requireSuccessfulPayment, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 d01c00ee6..c29a8369b 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -223,7 +223,7 @@ constructor( checkNotNull(threshold) { "`threshold` is required but was not set" }, expiresAfter, expiresAfterUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -409,9 +409,9 @@ constructor( checkNotNull(threshold) { "`threshold` is required but was not set" }, expiresAfter, expiresAfterUnit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -525,7 +525,7 @@ constructor( checkNotNull(netTerms) { "`netTerms` is required but was not set" }, memo, requireSuccessfulPayment, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt index 2b2de9f93..7e5cf5624 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -263,7 +263,7 @@ private constructor( invoiceSettings, expiresAfter, expiresAfterUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -440,7 +440,7 @@ private constructor( netTerms, memo, requireSuccessfulPayment, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 539e1ab10..db5b1e5ff 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 @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -155,9 +155,9 @@ constructor( "`externalCustomerId` is required but was not set" }, checkNotNull(topUpId) { "`topUpId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 04d74e4b5..122c7725f 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 @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -148,9 +148,9 @@ constructor( CustomerCreditTopUpDeleteParams( checkNotNull(customerId) { "`customerId` is required but was not set" }, checkNotNull(topUpId) { "`topUpId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 49df4cce9..ac7d5f7e9 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.Objects import java.util.Optional @@ -186,7 +186,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 41c9b92b3..8227ca1fe 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.Objects import java.util.Optional @@ -189,7 +189,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 531e3f01f..9d0d4bbd7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -29,7 +29,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -147,8 +147,8 @@ constructor( }, cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt index 9f89af8fd..6913a8db0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -264,7 +264,7 @@ private constructor( invoiceSettings, expiresAfter, expiresAfterUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -441,7 +441,7 @@ private constructor( netTerms, memo, requireSuccessfulPayment, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 860ecb7cb..9618ced9e 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.Objects import java.util.Optional @@ -183,7 +183,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 10aa8b4df..748fc4a2a 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.Objects import java.util.Optional @@ -186,7 +186,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 433cf1c37..a9c8c3cb0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -29,7 +29,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -141,8 +141,8 @@ constructor( checkNotNull(customerId) { "`customerId` is required but was not set" }, cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt index 3139f25b2..2698be307 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -263,7 +263,7 @@ private constructor( invoiceSettings, expiresAfter, expiresAfterUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -440,7 +440,7 @@ private constructor( netTerms, memo, requireSuccessfulPayment, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 0e0d4e577..d84ec8e0f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -138,9 +138,9 @@ constructor( fun build(): CustomerDeleteParams = CustomerDeleteParams( checkNotNull(customerId) { "`customerId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 da5afffff..bfad4843d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -117,8 +117,8 @@ constructor( checkNotNull(externalCustomerId) { "`externalCustomerId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 6b6add7a8..bbc48f421 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): CustomerFetchParams = CustomerFetchParams( checkNotNull(customerId) { "`customerId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 fcd25c164..ac6308249 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.CustomerService import java.util.Objects import java.util.Optional @@ -176,7 +176,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 1adc882a0..61cb3cb64 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.CustomerServiceAsync import java.util.Objects import java.util.Optional @@ -183,7 +183,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 1cff794aa..2969e7cc7 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.time.format.DateTimeFormatter @@ -52,7 +52,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -172,8 +172,8 @@ constructor( createdAtLte, cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 f9b6bcaba..6daa87a35 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -602,7 +602,7 @@ constructor( fun build(): CustomerUpdateByExternalIdBody = CustomerUpdateByExternalIdBody( accountingSyncConfiguration, - additionalEmails?.toUnmodifiable(), + additionalEmails?.toImmutable(), autoCollection, billingAddress, currency, @@ -617,7 +617,7 @@ constructor( shippingAddress, taxConfiguration, taxId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -995,7 +995,7 @@ constructor( CustomerUpdateByExternalIdParams( checkNotNull(id) { "`id` is required but was not set" }, accountingSyncConfiguration, - if (additionalEmails.size == 0) null else additionalEmails.toUnmodifiable(), + if (additionalEmails.size == 0) null else additionalEmails.toImmutable(), autoCollection, billingAddress, currency, @@ -1010,9 +1010,9 @@ constructor( shippingAddress, taxConfiguration, taxId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -1079,8 +1079,8 @@ constructor( fun build(): AccountingSyncConfiguration = AccountingSyncConfiguration( excluded, - accountingProviders?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + accountingProviders?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -1151,7 +1151,7 @@ constructor( checkNotNull(externalProviderId) { "`externalProviderId` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1289,7 +1289,7 @@ constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1360,7 +1360,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1509,7 +1509,7 @@ constructor( fun build(): ReportingConfiguration = ReportingConfiguration( checkNotNull(exempt) { "`exempt` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -1626,7 +1626,7 @@ constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1905,7 +1905,7 @@ constructor( taxExempt, taxProvider, taxExemptionCode, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2065,7 +2065,7 @@ constructor( NewTaxJarConfiguration( taxExempt, taxProvider, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2316,7 +2316,7 @@ constructor( checkNotNull(country) { "`country` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, checkNotNull(value) { "`value` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 4a2d299c7..fea9c9567 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -599,7 +599,7 @@ constructor( fun build(): CustomerUpdateBody = CustomerUpdateBody( accountingSyncConfiguration, - additionalEmails?.toUnmodifiable(), + additionalEmails?.toImmutable(), autoCollection, billingAddress, currency, @@ -614,7 +614,7 @@ constructor( shippingAddress, taxConfiguration, taxId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -989,7 +989,7 @@ constructor( CustomerUpdateParams( checkNotNull(customerId) { "`customerId` is required but was not set" }, accountingSyncConfiguration, - if (additionalEmails.size == 0) null else additionalEmails.toUnmodifiable(), + if (additionalEmails.size == 0) null else additionalEmails.toImmutable(), autoCollection, billingAddress, currency, @@ -1004,9 +1004,9 @@ constructor( shippingAddress, taxConfiguration, taxId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -1073,8 +1073,8 @@ constructor( fun build(): AccountingSyncConfiguration = AccountingSyncConfiguration( excluded, - accountingProviders?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + accountingProviders?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -1145,7 +1145,7 @@ constructor( checkNotNull(externalProviderId) { "`externalProviderId` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1283,7 +1283,7 @@ constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1354,7 +1354,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1503,7 +1503,7 @@ constructor( fun build(): ReportingConfiguration = ReportingConfiguration( checkNotNull(exempt) { "`exempt` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -1620,7 +1620,7 @@ constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1899,7 +1899,7 @@ constructor( taxExempt, taxProvider, taxExemptionCode, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2059,7 +2059,7 @@ constructor( NewTaxJarConfiguration( taxExempt, taxProvider, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2310,7 +2310,7 @@ constructor( checkNotNull(country) { "`country` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, checkNotNull(value) { "`value` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 683c71457..c212c7ade 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -357,10 +357,10 @@ private constructor( fun build(): UsageDiscount = UsageDiscount( discountType, - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, usageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 d84057348..0f0d72a08 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,7 +20,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -133,10 +133,10 @@ private constructor( fun build(): EvaluatePriceGroup = EvaluatePriceGroup( - groupingValues.map { it.toUnmodifiable() }, + groupingValues.map { it.toImmutable() }, quantity, amount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 fb6452c03..95257f919 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -138,9 +138,9 @@ constructor( fun build(): EventBackfillCloseParams = EventBackfillCloseParams( checkNotNull(backfillId) { "`backfillId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt index 7cb9732aa..c65bd5951 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -299,7 +299,7 @@ private constructor( revertedAt, customerId, deprecationFilter, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 de2336dfe..602001ccf 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.util.Objects @@ -226,7 +226,7 @@ constructor( deprecationFilter, externalCustomerId, replaceExistingEvents, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -416,9 +416,9 @@ constructor( deprecationFilter, externalCustomerId, replaceExistingEvents, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt index c1dabccb9..083918bba 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -299,7 +299,7 @@ private constructor( revertedAt, customerId, deprecationFilter, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 7da0d8da1..fc6b6cc2f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): EventBackfillFetchParams = EventBackfillFetchParams( checkNotNull(backfillId) { "`backfillId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt index 366d88210..20816af80 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -299,7 +299,7 @@ private constructor( revertedAt, customerId, deprecationFilter, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 02b5f0d7c..5d0cd1a67 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.events.BackfillService import java.util.Objects import java.util.Optional @@ -181,7 +181,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 2fa75994e..03ce748c5 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.events.BackfillServiceAsync import java.util.Objects import java.util.Optional @@ -184,7 +184,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 08590c2de..1876e774d 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -26,7 +26,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -126,8 +126,8 @@ constructor( EventBackfillListParams( cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt index 6fbccd242..e368f7816 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -299,7 +299,7 @@ private constructor( revertedAt, customerId, deprecationFilter, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 111f74637..95f7cd1c5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -138,9 +138,9 @@ constructor( fun build(): EventBackfillRevertParams = EventBackfillRevertParams( checkNotNull(backfillId) { "`backfillId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt index 40fff0614..326fc1efa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -299,7 +299,7 @@ private constructor( revertedAt, customerId, deprecationFilter, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 a5e2b6654..f7b684b03 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -138,9 +138,9 @@ constructor( fun build(): EventDeprecateParams = EventDeprecateParams( checkNotNull(eventId) { "`eventId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 7e196d6ba..75d904e5b 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.util.Objects @JsonDeserialize(builder = EventDeprecateResponse.Builder::class) @@ -82,7 +82,7 @@ private constructor( } fun build(): EventDeprecateResponse = - EventDeprecateResponse(deprecated, additionalProperties.toUnmodifiable()) + EventDeprecateResponse(deprecated, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 dcbaeea4c..ba5cb6aad 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.util.Objects @@ -42,7 +42,7 @@ constructor( this.backfillId?.let { params.put("backfill_id", listOf(it.toString())) } this.debug?.let { params.put("debug", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -97,9 +97,8 @@ constructor( fun build(): EventIngestBody = EventIngestBody( - checkNotNull(events) { "`events` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + additionalProperties.toImmutable() ) } @@ -244,12 +243,12 @@ constructor( fun build(): EventIngestParams = EventIngestParams( - checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), + checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), backfillId, debug, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -390,7 +389,7 @@ constructor( checkNotNull(timestamp) { "`timestamp` is required but was not set" }, checkNotNull(properties) { "`properties` is required but was not set" }, checkNotNull(idempotencyKey) { "`idempotencyKey` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 c358461ea..09bdae4d4 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,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional @@ -131,8 +131,8 @@ private constructor( fun build(): EventIngestResponse = EventIngestResponse( debug, - validationFailed.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + validationFailed.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -236,8 +236,8 @@ private constructor( fun build(): ValidationFailed = ValidationFailed( idempotencyKey, - validationErrors.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + validationErrors.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -345,9 +345,9 @@ private constructor( fun build(): Debug = Debug( - duplicate.map { it.toUnmodifiable() }, - ingested.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + duplicate.map { it.toImmutable() }, + ingested.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } 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 63a098404..6b1ac2c05 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.util.Objects @@ -143,10 +143,10 @@ constructor( fun build(): EventSearchBody = EventSearchBody( checkNotNull(eventIds) { "`eventIds` is required but was not set" } - .toUnmodifiable(), + .toImmutable(), timeframeEnd, timeframeStart, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -306,13 +306,12 @@ constructor( fun build(): EventSearchParams = EventSearchParams( - checkNotNull(eventIds) { "`eventIds` is required but was not set" } - .toUnmodifiable(), + checkNotNull(eventIds) { "`eventIds` is required but was not set" }.toImmutable(), timeframeEnd, timeframeStart, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 65355c898..6f3805d5b 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,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -80,10 +80,7 @@ private constructor( } fun build(): EventSearchResponse = - EventSearchResponse( - data.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) + EventSearchResponse(data.map { it.toImmutable() }, additionalProperties.toImmutable()) } /** @@ -319,7 +316,7 @@ private constructor( properties, timestamp, deprecated, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 876724c90..56b8b3817 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.util.Objects @@ -179,7 +179,7 @@ constructor( checkNotNull(timestamp) { "`timestamp` is required but was not set" }, customerId, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -346,9 +346,9 @@ constructor( checkNotNull(timestamp) { "`timestamp` is required but was not set" }, customerId, externalCustomerId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 0e2e8f5a2..5fc1a2a2e 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.util.Objects @JsonDeserialize(builder = EventUpdateResponse.Builder::class) @@ -82,7 +82,7 @@ private constructor( } fun build(): EventUpdateResponse = - EventUpdateResponse(amended, additionalProperties.toUnmodifiable()) + EventUpdateResponse(amended, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 efcc767b1..9012eb84f 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.time.format.DateTimeFormatter @@ -40,7 +40,7 @@ constructor( params.put("timeframe_end", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -163,8 +163,8 @@ constructor( cursor, limit, timeframeEnd, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 2146dc37d..a776a5f01 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,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.time.OffsetDateTime import java.util.Objects @@ -79,7 +79,7 @@ private constructor( } fun build(): EventVolumes = - EventVolumes(data.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable()) + EventVolumes(data.map { it.toImmutable() }, additionalProperties.toImmutable()) } /** @@ -192,7 +192,7 @@ private constructor( timeframeStart, timeframeEnd, count, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 7fa660d67..3e0fc564b 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -1426,7 +1426,7 @@ private constructor( currency, customer, discount, - discounts.map { it.toUnmodifiable() }, + discounts.map { it.toImmutable() }, dueDate, id, invoicePdf, @@ -1435,11 +1435,11 @@ private constructor( minimumAmount, maximum, maximumAmount, - lineItems.map { it.toUnmodifiable() }, + lineItems.map { it.toImmutable() }, subscription, subtotal, total, - customerBalanceTransactions.map { it.toUnmodifiable() }, + customerBalanceTransactions.map { it.toImmutable() }, status, invoiceSource, shippingAddress, @@ -1449,9 +1449,9 @@ private constructor( eligibleToIssueAt, customerTaxId, memo, - creditNotes.map { it.toUnmodifiable() }, + creditNotes.map { it.toImmutable() }, invoiceDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1637,7 +1637,7 @@ private constructor( previouslyAttemptedAt, enabled, numAttempts, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1804,7 +1804,7 @@ private constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2011,7 +2011,7 @@ private constructor( voidedAt, type, memo, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2123,7 +2123,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2410,7 +2410,7 @@ private constructor( invoice, type, creditNote, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2576,7 +2576,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): CreditNote = CreditNote(id, additionalProperties.toUnmodifiable()) + fun build(): CreditNote = CreditNote(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2668,7 +2668,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Invoice = Invoice(id, additionalProperties.toUnmodifiable()) + fun build(): Invoice = Invoice(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2971,7 +2971,7 @@ private constructor( country, type, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5331,11 +5331,11 @@ private constructor( quantity, startDate, subtotal, - subLineItems.map { it.toUnmodifiable() }, - taxAmounts.map { it.toUnmodifiable() }, + subLineItems.map { it.toImmutable() }, + taxAmounts.map { it.toImmutable() }, id, price, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5449,8 +5449,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -5585,8 +5585,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -5929,7 +5929,7 @@ private constructor( grouping, type, matrixConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6020,7 +6020,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6122,8 +6122,8 @@ private constructor( fun build(): MatrixConfig = MatrixConfig( - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -6370,7 +6370,7 @@ private constructor( grouping, type, tierConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6461,7 +6461,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6591,7 +6591,7 @@ private constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6821,7 +6821,7 @@ private constructor( quantity, grouping, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6912,7 +6912,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7132,7 +7132,7 @@ private constructor( taxRateDescription, taxRatePercentage, amount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7286,8 +7286,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -7366,7 +7366,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -7497,8 +7497,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -7665,7 +7665,7 @@ private constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7828,7 +7828,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Subscription = Subscription(id, additionalProperties.toUnmodifiable()) + fun build(): Subscription = Subscription(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 aed4dd81f..f138e7f8d 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.LocalDate @@ -269,7 +269,7 @@ constructor( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(invoiceDate) { "`invoiceDate` is required but was not set" }, checkNotNull(lineItems) { "`lineItems` is required but was not set" } - .toUnmodifiable(), + .toImmutable(), checkNotNull(netTerms) { "`netTerms` is required but was not set" }, customerId, discount, @@ -277,7 +277,7 @@ constructor( memo, metadata, willAutoIssue, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -500,8 +500,7 @@ constructor( InvoiceCreateParams( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(invoiceDate) { "`invoiceDate` is required but was not set" }, - checkNotNull(lineItems) { "`lineItems` is required but was not set" } - .toUnmodifiable(), + checkNotNull(lineItems) { "`lineItems` is required but was not set" }.toImmutable(), checkNotNull(netTerms) { "`netTerms` is required but was not set" }, customerId, discount, @@ -509,9 +508,9 @@ constructor( memo, metadata, willAutoIssue, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -627,7 +626,7 @@ constructor( checkNotNull(itemId) { "`itemId` is required but was not set" }, checkNotNull(modelType) { "`modelType` is required but was not set" }, checkNotNull(unitConfig) { "`unitConfig` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -737,7 +736,7 @@ constructor( fun build(): UnitConfig = UnitConfig( checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -829,7 +828,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 8e5b07f07..642d821df 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): InvoiceFetchParams = InvoiceFetchParams( checkNotNull(invoiceId) { "`invoiceId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 06e5ae206..f8f652830 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -21,7 +21,7 @@ constructor( val params = mutableMapOf>() this.subscriptionId.let { params.put("subscription_id", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -111,8 +111,8 @@ constructor( fun build(): InvoiceFetchUpcomingParams = InvoiceFetchUpcomingParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 06d844caa..c82f49cf8 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -1420,7 +1420,7 @@ private constructor( currency, customer, discount, - discounts.map { it.toUnmodifiable() }, + discounts.map { it.toImmutable() }, dueDate, id, invoicePdf, @@ -1429,11 +1429,11 @@ private constructor( minimumAmount, maximum, maximumAmount, - lineItems.map { it.toUnmodifiable() }, + lineItems.map { it.toImmutable() }, subscription, subtotal, total, - customerBalanceTransactions.map { it.toUnmodifiable() }, + customerBalanceTransactions.map { it.toImmutable() }, status, invoiceSource, shippingAddress, @@ -1443,9 +1443,9 @@ private constructor( eligibleToIssueAt, customerTaxId, memo, - creditNotes.map { it.toUnmodifiable() }, + creditNotes.map { it.toImmutable() }, targetDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1631,7 +1631,7 @@ private constructor( previouslyAttemptedAt, enabled, numAttempts, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1798,7 +1798,7 @@ private constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2005,7 +2005,7 @@ private constructor( voidedAt, type, memo, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2117,7 +2117,7 @@ private constructor( Customer( id, externalCustomerId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2404,7 +2404,7 @@ private constructor( invoice, type, creditNote, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2570,7 +2570,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): CreditNote = CreditNote(id, additionalProperties.toUnmodifiable()) + fun build(): CreditNote = CreditNote(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2662,7 +2662,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Invoice = Invoice(id, additionalProperties.toUnmodifiable()) + fun build(): Invoice = Invoice(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2965,7 +2965,7 @@ private constructor( country, type, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5325,11 +5325,11 @@ private constructor( quantity, startDate, subtotal, - subLineItems.map { it.toUnmodifiable() }, - taxAmounts.map { it.toUnmodifiable() }, + subLineItems.map { it.toImmutable() }, + taxAmounts.map { it.toImmutable() }, id, price, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5443,8 +5443,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -5579,8 +5579,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -5923,7 +5923,7 @@ private constructor( grouping, type, matrixConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6014,7 +6014,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6116,8 +6116,8 @@ private constructor( fun build(): MatrixConfig = MatrixConfig( - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -6364,7 +6364,7 @@ private constructor( grouping, type, tierConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6455,7 +6455,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6585,7 +6585,7 @@ private constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6815,7 +6815,7 @@ private constructor( quantity, grouping, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6906,7 +6906,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7126,7 +7126,7 @@ private constructor( taxRateDescription, taxRatePercentage, amount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7280,8 +7280,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -7360,7 +7360,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -7491,8 +7491,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -7659,7 +7659,7 @@ private constructor( state, postalCode, country, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7822,7 +7822,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Subscription = Subscription(id, additionalProperties.toUnmodifiable()) + fun build(): Subscription = Subscription(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 6daf5b921..d3d993ba7 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -101,7 +101,7 @@ constructor( } fun build(): InvoiceIssueBody = - InvoiceIssueBody(synchronous, additionalProperties.toUnmodifiable()) + InvoiceIssueBody(synchronous, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -237,9 +237,9 @@ constructor( InvoiceIssueParams( checkNotNull(invoiceId) { "`invoiceId` is required but was not set" }, synchronous, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 5efa8819e..6a1d96b83 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.LocalDate import java.util.Objects @@ -169,7 +169,7 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(quantity) { "`quantity` is required but was not set" }, checkNotNull(startDate) { "`startDate` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -331,9 +331,9 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(quantity) { "`quantity` is required but was not set" }, checkNotNull(startDate) { "`startDate` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index b944c3eda..4d249152c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -1310,11 +1310,11 @@ private constructor( quantity, startDate, subtotal, - subLineItems.map { it.toUnmodifiable() }, - taxAmounts.map { it.toUnmodifiable() }, + subLineItems.map { it.toImmutable() }, + taxAmounts.map { it.toImmutable() }, id, price, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1426,8 +1426,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1560,8 +1560,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1892,7 +1892,7 @@ private constructor( grouping, type, matrixConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1982,7 +1982,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2083,8 +2083,8 @@ private constructor( fun build(): MatrixConfig = MatrixConfig( - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -2330,7 +2330,7 @@ private constructor( grouping, type, tierConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2420,7 +2420,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2547,7 +2547,7 @@ private constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2776,7 +2776,7 @@ private constructor( quantity, grouping, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2866,7 +2866,7 @@ private constructor( Grouping( key, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3083,7 +3083,7 @@ private constructor( taxRateDescription, taxRatePercentage, amount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 bd48576ca..58a1e6a23 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.InvoiceService import java.util.Objects import java.util.Optional @@ -176,7 +176,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 733448c15..be7965921 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.InvoiceServiceAsync import java.util.Objects import java.util.Optional @@ -183,7 +183,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 5dd0742d6..13255f150 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.LocalDate @@ -122,7 +122,7 @@ constructor( this.status?.let { params.put("status[]", it.map(Any::toString)) } this.subscriptionId?.let { params.put("subscription_id", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -320,10 +320,10 @@ constructor( invoiceDateLte, isRecurring, limit, - if (status.size == 0) null else status.toUnmodifiable(), + if (status.size == 0) null else status.toImmutable(), subscriptionId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 ff7ef05b6..5e4c0e07f 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.LocalDate import java.util.Objects @@ -135,7 +135,7 @@ constructor( }, externalId, notes, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -285,9 +285,9 @@ constructor( }, externalId, notes, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 e079de287..b563fe157 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -103,7 +103,7 @@ constructor( } fun build(): InvoiceUpdateBody = - InvoiceUpdateBody(metadata, additionalProperties.toUnmodifiable()) + InvoiceUpdateBody(metadata, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -240,9 +240,9 @@ constructor( InvoiceUpdateParams( checkNotNull(invoiceId) { "`invoiceId` is required but was not set" }, metadata, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -292,7 +292,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 8c6e47504..57d336cfd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -138,9 +138,9 @@ constructor( fun build(): InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams( checkNotNull(invoiceId) { "`invoiceId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 bf9b38e81..181aa950e 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -137,8 +137,8 @@ private constructor( id, name, createdAt, - externalConnections.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + externalConnections.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -235,7 +235,7 @@ private constructor( ExternalConnection( externalConnectionName, externalEntityId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 6c107d01a..6bd96c6a1 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -85,7 +85,7 @@ constructor( fun build(): ItemCreateBody = ItemCreateBody( checkNotNull(name) { "`name` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -214,9 +214,9 @@ constructor( fun build(): ItemCreateParams = ItemCreateParams( checkNotNull(name) { "`name` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 b3b524e29..da921feaa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): ItemFetchParams = ItemFetchParams( checkNotNull(itemId) { "`itemId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 64dc18ed7..8cff8ee69 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.ItemService import java.util.Objects import java.util.Optional @@ -175,7 +175,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 d33b7f7fd..bfea12c64 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.ItemServiceAsync import java.util.Objects import java.util.Optional @@ -178,7 +178,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 384654713..36bd81481 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -26,7 +26,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -126,8 +126,8 @@ constructor( ItemListParams( cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 643725399..1bc4e0f0d 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -121,9 +121,9 @@ constructor( fun build(): ItemUpdateBody = ItemUpdateBody( - externalConnections?.toUnmodifiable(), + externalConnections?.toImmutable(), name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -266,11 +266,11 @@ constructor( fun build(): ItemUpdateParams = ItemUpdateParams( checkNotNull(itemId) { "`itemId` is required but was not set" }, - if (externalConnections.size == 0) null else externalConnections.toUnmodifiable(), + if (externalConnections.size == 0) null else externalConnections.toImmutable(), name, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -344,7 +344,7 @@ constructor( checkNotNull(externalEntityId) { "`externalEntityId` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 60cad8531..736982109 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -155,7 +155,7 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(sql) { "`sql` is required but was not set" }, metadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -312,9 +312,9 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(sql) { "`sql` is required but was not set" }, metadata, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -364,7 +364,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 39d699943..05e0222cc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): MetricFetchParams = MetricFetchParams( checkNotNull(metricId) { "`metricId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 8e01af438..f886c982b 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.MetricService import java.util.Objects import java.util.Optional @@ -176,7 +176,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 0a46107e6..ba125f7de 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.MetricServiceAsync import java.util.Objects import java.util.Optional @@ -179,7 +179,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 ec45f939b..5aa525a54 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.time.format.DateTimeFormatter @@ -52,7 +52,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -172,8 +172,8 @@ constructor( createdAtLte, cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 af57061ff..bbc15f9ae 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -103,7 +103,7 @@ constructor( } fun build(): MetricUpdateBody = - MetricUpdateBody(metadata, additionalProperties.toUnmodifiable()) + MetricUpdateBody(metadata, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -240,9 +240,9 @@ constructor( MetricUpdateParams( checkNotNull(metricId) { "`metricId` is required but was not set" }, metadata, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -292,7 +292,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 812e924d4..3d9ced28d 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional @@ -96,7 +96,7 @@ private constructor( PaginationMetadata( hasMore, nextCursor, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 4a894f353..7d4d47b73 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -158,10 +158,10 @@ private constructor( fun build(): PercentageDiscount = PercentageDiscount( discountType, - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 93d31bfa6..60796ffc2 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -566,7 +566,7 @@ private constructor( product, version, trialConfig, - planPhases.map { it.toUnmodifiable() }, + planPhases.map { it.toImmutable() }, basePlan, basePlanId, externalPlanId, @@ -574,8 +574,8 @@ private constructor( invoicingCurrency, netTerms, defaultInvoiceMemo, - prices.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + prices.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -699,7 +699,7 @@ private constructor( id, externalPlanId, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -832,8 +832,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -912,7 +912,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1043,8 +1043,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1317,7 +1317,7 @@ private constructor( maximumAmount, minimumAmount, discount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1506,8 +1506,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1642,8 +1642,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1787,7 +1787,7 @@ private constructor( createdAt, id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1960,7 +1960,7 @@ private constructor( TrialConfig( trialPeriod, trialPeriodUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 bf5e8e828..d1bbba780 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,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -227,14 +227,13 @@ constructor( PlanCreateBody( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(prices) { "`prices` is required but was not set" } - .toUnmodifiable(), + checkNotNull(prices) { "`prices` is required but was not set" }.toImmutable(), defaultInvoiceMemo, externalPlanId, metadata, netTerms, status, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -421,15 +420,15 @@ constructor( PlanCreateParams( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(prices) { "`prices` is required but was not set" }.toUnmodifiable(), + checkNotNull(prices) { "`prices` is required but was not set" }.toImmutable(), defaultInvoiceMemo, externalPlanId, metadata, netTerms, status, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -1645,7 +1644,7 @@ constructor( modelType, unitConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1852,7 +1851,7 @@ constructor( } fun build(): UnitConfig = - UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + UnitConfig(unitAmount, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1973,7 +1972,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2154,7 +2153,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2292,7 +2291,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2808,7 +2807,7 @@ constructor( modelType, packageConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3051,7 +3050,7 @@ constructor( PackageConfig( packageAmount, packageSize, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3173,7 +3172,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3354,7 +3353,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3492,7 +3491,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4008,7 +4007,7 @@ constructor( modelType, matrixConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4220,10 +4219,10 @@ constructor( fun build(): MatrixConfig = MatrixConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + matrixValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -4341,8 +4340,8 @@ constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -4536,7 +4535,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4717,7 +4716,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4855,7 +4854,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5371,7 +5370,7 @@ constructor( modelType, tieredConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5577,8 +5576,8 @@ constructor( fun build(): TieredConfig = TieredConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -5703,7 +5702,7 @@ constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5846,7 +5845,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6027,7 +6026,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6165,7 +6164,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -6684,7 +6683,7 @@ constructor( modelType, tieredBpsConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6902,8 +6901,8 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -7053,7 +7052,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7196,7 +7195,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7377,7 +7376,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7515,7 +7514,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -8029,7 +8028,7 @@ constructor( modelType, bpsConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8129,7 +8128,7 @@ constructor( BpsConfig( bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8383,7 +8382,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8564,7 +8563,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8702,7 +8701,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -9218,7 +9217,7 @@ constructor( modelType, bulkBpsConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9304,8 +9303,8 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -9431,7 +9430,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9706,7 +9705,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9887,7 +9886,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10025,7 +10024,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -10539,7 +10538,7 @@ constructor( modelType, bulkConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10613,8 +10612,8 @@ constructor( fun build(): BulkConfig = BulkConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -10717,7 +10716,7 @@ constructor( Tier( maximumUnits, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10992,7 +10991,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11173,7 +11172,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11311,7 +11310,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -11836,7 +11835,7 @@ constructor( modelType, thresholdTotalAmountConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12025,7 +12024,7 @@ constructor( } fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -12146,7 +12145,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12327,7 +12326,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12465,7 +12464,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -12986,7 +12985,7 @@ constructor( modelType, tieredPackageConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13173,7 +13172,7 @@ constructor( } fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) + TieredPackageConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -13294,7 +13293,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13475,7 +13474,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13613,7 +13612,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -14136,7 +14135,7 @@ constructor( modelType, tieredWithMinimumConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14324,7 +14323,7 @@ constructor( } fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -14445,7 +14444,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14626,7 +14625,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14764,7 +14763,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15288,7 +15287,7 @@ constructor( modelType, unitWithPercentConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15475,7 +15474,7 @@ constructor( } fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) + UnitWithPercentConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15596,7 +15595,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15777,7 +15776,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15915,7 +15914,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16440,7 +16439,7 @@ constructor( modelType, packageWithAllocationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16629,7 +16628,7 @@ constructor( } fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + PackageWithAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16750,7 +16749,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16931,7 +16930,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17069,7 +17068,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17593,7 +17592,7 @@ constructor( modelType, tieredWithProrationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17782,7 +17781,7 @@ constructor( } fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + TieredWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17903,7 +17902,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18084,7 +18083,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18222,7 +18221,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18745,7 +18744,7 @@ constructor( modelType, unitWithProrationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18933,7 +18932,7 @@ constructor( } fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) + UnitWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19054,7 +19053,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19235,7 +19234,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19373,7 +19372,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19896,7 +19895,7 @@ constructor( modelType, groupedAllocationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20032,7 +20031,7 @@ constructor( } fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + GroupedAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20204,7 +20203,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20385,7 +20384,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20523,7 +20522,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -21056,7 +21055,7 @@ constructor( modelType, groupedWithProratedMinimumConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21194,7 +21193,7 @@ constructor( } fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -21368,7 +21367,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21549,7 +21548,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21687,7 +21686,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22215,7 +22214,7 @@ constructor( modelType, groupedWithMeteredMinimumConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22353,7 +22352,7 @@ constructor( } fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22527,7 +22526,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22708,7 +22707,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22846,7 +22845,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23371,7 +23370,7 @@ constructor( modelType, matrixWithDisplayNameConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23508,7 +23507,7 @@ constructor( } fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toUnmodifiable()) + MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23682,7 +23681,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23863,7 +23862,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -24001,7 +24000,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24524,7 +24523,7 @@ constructor( modelType, bulkWithProrationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -24579,7 +24578,7 @@ constructor( } fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toUnmodifiable()) + BulkWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24833,7 +24832,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25014,7 +25013,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25152,7 +25151,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -25243,7 +25242,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 9b794f5dd..327e00f16 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams( checkNotNull(externalPlanId) { "`externalPlanId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 1e4a0e06b..baf8aaaf6 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -133,7 +133,7 @@ constructor( PlanExternalPlanIdUpdateBody( externalPlanId, metadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -285,9 +285,9 @@ constructor( }, externalPlanId, metadata, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -337,7 +337,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 4b183127a..764e01217 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): PlanFetchParams = PlanFetchParams( checkNotNull(planId) { "`planId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 10b0a2047..547aa4c3a 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.PlanService import java.util.Objects import java.util.Optional @@ -175,7 +175,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 c16c6dc6d..725692219 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.PlanServiceAsync import java.util.Objects import java.util.Optional @@ -178,7 +178,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 2b5ce0e3c..535081fc8 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -61,7 +61,7 @@ constructor( this.limit?.let { params.put("limit", listOf(it.toString())) } this.status?.let { params.put("status", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -187,8 +187,8 @@ constructor( cursor, limit, status, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 24cce6c0a..0c6a6fd78 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -133,7 +133,7 @@ constructor( PlanUpdateBody( externalPlanId, metadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -281,9 +281,9 @@ constructor( checkNotNull(planId) { "`planId` is required but was not set" }, externalPlanId, metadata, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -333,7 +333,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 296cbb786..8232fcd6f 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -1216,7 +1216,7 @@ private constructor( maximum, maximumAmount, unitConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1284,8 +1284,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1394,7 +1393,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1642,7 +1641,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1753,7 +1752,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1917,7 +1916,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2052,8 +2051,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -2133,7 +2132,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2266,8 +2265,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -2470,8 +2469,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): UnitConfig = - UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + fun build(): UnitConfig = UnitConfig(unitAmount, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2987,7 +2985,7 @@ private constructor( maximum, maximumAmount, packageConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3055,8 +3053,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -3165,7 +3162,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3413,7 +3410,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3524,7 +3521,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3688,7 +3685,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3823,8 +3820,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -3904,7 +3901,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4037,8 +4034,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -4221,7 +4218,7 @@ private constructor( PackageConfig( packageAmount, packageSize, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4794,7 +4791,7 @@ private constructor( maximum, maximumAmount, matrixConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4862,8 +4859,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4972,7 +4968,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5220,7 +5216,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5331,7 +5327,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5495,7 +5491,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5640,10 +5636,10 @@ private constructor( fun build(): MatrixConfig = MatrixConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + matrixValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -5760,8 +5756,8 @@ private constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -5917,8 +5913,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -5998,7 +5994,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -6131,8 +6127,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -6756,7 +6752,7 @@ private constructor( maximum, maximumAmount, tieredConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6824,8 +6820,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -6934,7 +6929,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7182,7 +7177,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7293,7 +7288,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7457,7 +7452,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7592,8 +7587,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -7673,7 +7668,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -7806,8 +7801,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -8009,10 +8004,7 @@ private constructor( } fun build(): TieredConfig = - TieredConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) + TieredConfig(tiers.map { it.toImmutable() }, additionalProperties.toImmutable()) } @JsonDeserialize(builder = Tier.Builder::class) @@ -8129,7 +8121,7 @@ private constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8667,7 +8659,7 @@ private constructor( maximum, maximumAmount, tieredBpsConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8735,8 +8727,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -8845,7 +8836,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9093,7 +9084,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9204,7 +9195,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9368,7 +9359,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9503,8 +9494,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -9584,7 +9575,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -9717,8 +9708,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -9931,8 +9922,8 @@ private constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -10077,7 +10068,7 @@ private constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10612,7 +10603,7 @@ private constructor( maximum, maximumAmount, bpsConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10680,8 +10671,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -10790,7 +10780,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10966,7 +10956,7 @@ private constructor( BpsConfig( bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11157,7 +11147,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11268,7 +11258,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11432,7 +11422,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11567,8 +11557,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -11648,7 +11638,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -11781,8 +11771,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -12407,7 +12397,7 @@ private constructor( maximum, maximumAmount, bulkBpsConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12475,8 +12465,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -12585,7 +12574,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12749,8 +12738,8 @@ private constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -12873,7 +12862,7 @@ private constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13085,7 +13074,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13196,7 +13185,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13360,7 +13349,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13495,8 +13484,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -13576,7 +13565,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -13709,8 +13698,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -14334,7 +14323,7 @@ private constructor( maximum, maximumAmount, bulkConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14402,8 +14391,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -14512,7 +14500,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14663,10 +14651,7 @@ private constructor( } fun build(): BulkConfig = - BulkConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) + BulkConfig(tiers.map { it.toImmutable() }, additionalProperties.toImmutable()) } @JsonDeserialize(builder = Tier.Builder::class) @@ -14765,7 +14750,7 @@ private constructor( Tier( maximumUnits, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14977,7 +14962,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15088,7 +15073,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15252,7 +15237,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15387,8 +15372,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -15468,7 +15453,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15601,8 +15586,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -16233,7 +16218,7 @@ private constructor( maximum, maximumAmount, thresholdTotalAmountConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16301,8 +16286,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16411,7 +16395,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16659,7 +16643,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16770,7 +16754,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16934,7 +16918,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17069,8 +17053,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -17150,7 +17134,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17283,8 +17267,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -17469,7 +17453,7 @@ private constructor( } fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17988,7 +17972,7 @@ private constructor( maximum, maximumAmount, tieredPackageConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18056,8 +18040,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18166,7 +18149,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18414,7 +18397,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18525,7 +18508,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18689,7 +18672,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18824,8 +18807,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -18905,7 +18888,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19038,8 +19021,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -19223,7 +19206,7 @@ private constructor( } fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) + TieredPackageConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19742,7 +19725,7 @@ private constructor( maximum, maximumAmount, groupedTieredConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19810,8 +19793,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19920,7 +19902,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20168,7 +20150,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20244,7 +20226,7 @@ private constructor( } fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toUnmodifiable()) + GroupedTieredConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20354,7 +20336,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20518,7 +20500,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20653,8 +20635,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -20734,7 +20716,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20867,8 +20849,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -21498,7 +21480,7 @@ private constructor( maximum, maximumAmount, tieredWithMinimumConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21566,8 +21548,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -21676,7 +21657,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21924,7 +21905,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22035,7 +22016,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22199,7 +22180,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22334,8 +22315,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -22415,7 +22396,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22548,8 +22529,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -22733,7 +22714,7 @@ private constructor( } fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23258,7 +23239,7 @@ private constructor( maximum, maximumAmount, tieredPackageWithMinimumConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23326,8 +23307,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23436,7 +23416,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23684,7 +23664,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23795,7 +23775,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23959,7 +23939,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -24094,8 +24074,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -24175,7 +24155,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24308,8 +24288,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -24496,7 +24476,7 @@ private constructor( } fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -25020,7 +25000,7 @@ private constructor( maximum, maximumAmount, packageWithAllocationConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25088,8 +25068,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -25198,7 +25177,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25446,7 +25425,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25557,7 +25536,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25721,7 +25700,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25856,8 +25835,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -25937,7 +25916,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26070,8 +26049,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -26200,7 +26179,7 @@ private constructor( } fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + PackageWithAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26777,7 +26756,7 @@ private constructor( maximum, maximumAmount, unitWithPercentConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26845,8 +26824,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26955,7 +26933,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27203,7 +27181,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27314,7 +27292,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27478,7 +27456,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27613,8 +27591,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -27694,7 +27672,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -27827,8 +27805,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -28012,7 +27990,7 @@ private constructor( } fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) + UnitWithPercentConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -28534,7 +28512,7 @@ private constructor( maximum, maximumAmount, matrixWithAllocationConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -28602,8 +28580,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -28712,7 +28689,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -28960,7 +28937,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29071,7 +29048,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29235,7 +29212,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29400,11 +29377,11 @@ private constructor( fun build(): MatrixWithAllocationConfig = MatrixWithAllocationConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, + matrixValues.map { it.toImmutable() }, allocation, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29521,8 +29498,8 @@ private constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -29678,8 +29655,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -29759,7 +29736,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -29892,8 +29869,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -30524,7 +30501,7 @@ private constructor( maximum, maximumAmount, tieredWithProrationConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -30592,8 +30569,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -30702,7 +30678,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -30950,7 +30926,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31061,7 +31037,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31225,7 +31201,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31360,8 +31336,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -31441,7 +31417,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -31574,8 +31550,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -31760,7 +31736,7 @@ private constructor( } fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + TieredWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -32281,7 +32257,7 @@ private constructor( maximum, maximumAmount, unitWithProrationConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32349,8 +32325,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -32459,7 +32434,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32707,7 +32682,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32818,7 +32793,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32982,7 +32957,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -33117,8 +33092,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -33198,7 +33173,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -33331,8 +33306,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -33516,7 +33491,7 @@ private constructor( } fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) + UnitWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -34037,7 +34012,7 @@ private constructor( maximum, maximumAmount, groupedAllocationConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34105,8 +34080,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -34215,7 +34189,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34463,7 +34437,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34539,7 +34513,7 @@ private constructor( } fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + GroupedAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -34649,7 +34623,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34813,7 +34787,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34948,8 +34922,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -35029,7 +35003,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -35162,8 +35136,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -35798,7 +35772,7 @@ private constructor( maximum, maximumAmount, groupedWithProratedMinimumConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -35866,8 +35840,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -35976,7 +35949,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36224,7 +36197,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36302,7 +36275,7 @@ private constructor( } fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -36412,7 +36385,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36576,7 +36549,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36711,8 +36684,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -36792,7 +36765,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -36925,8 +36898,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -37563,7 +37536,7 @@ private constructor( maximum, maximumAmount, groupedWithMeteredMinimumConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -37631,8 +37604,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -37741,7 +37713,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -37989,7 +37961,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38067,7 +38039,7 @@ private constructor( } fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -38177,7 +38149,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38341,7 +38313,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38476,8 +38448,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -38557,7 +38529,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -38690,8 +38662,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -39326,7 +39298,7 @@ private constructor( maximum, maximumAmount, matrixWithDisplayNameConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39394,8 +39366,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -39504,7 +39475,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39752,7 +39723,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39863,7 +39834,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -40027,7 +39998,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -40104,7 +40075,7 @@ private constructor( } fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toUnmodifiable()) + MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -40238,8 +40209,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -40319,7 +40290,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -40452,8 +40423,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -41084,7 +41055,7 @@ private constructor( maximum, maximumAmount, bulkWithProrationConfig, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41152,8 +41123,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BillableMetric = - BillableMetric(id, additionalProperties.toUnmodifiable()) + fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -41262,7 +41232,7 @@ private constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41395,7 +41365,7 @@ private constructor( } fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toUnmodifiable()) + BulkWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -41585,7 +41555,7 @@ private constructor( CreditAllocation( currency, allowsRollover, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41696,7 +41666,7 @@ private constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41860,7 +41830,7 @@ private constructor( Item( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41995,8 +41965,8 @@ private constructor( fun build(): Maximum = Maximum( maximumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -42076,7 +42046,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -42209,8 +42179,8 @@ private constructor( fun build(): Minimum = Minimum( minimumAmount, - appliesToPriceIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } 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 8079b3f80..34f3712ac 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 @@ -21,7 +21,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.util.Objects @@ -1855,8 +1855,8 @@ constructor( newFloatingGroupedWithMeteredMinimumPrice, newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } @@ -2108,7 +2108,7 @@ constructor( checkNotNull(modelType) { "`modelType` is required but was not set" }, checkNotNull(unitConfig) { "`unitConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2299,7 +2299,7 @@ constructor( fun build(): UnitConfig = UnitConfig( checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -2393,7 +2393,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2548,7 +2548,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2677,7 +2677,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2972,7 +2972,7 @@ constructor( checkNotNull(modelType) { "`modelType` is required but was not set" }, checkNotNull(packageConfig) { "`packageConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3184,7 +3184,7 @@ constructor( "`packageAmount` is required but was not set" }, checkNotNull(packageSize) { "`packageSize` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3278,7 +3278,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3433,7 +3433,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3562,7 +3562,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -3857,7 +3857,7 @@ constructor( checkNotNull(modelType) { "`modelType` is required but was not set" }, checkNotNull(matrixConfig) { "`matrixConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4024,13 +4024,13 @@ constructor( fun build(): MatrixConfig = MatrixConfig( checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toUnmodifiable(), + .toImmutable(), checkNotNull(defaultUnitAmount) { "`defaultUnitAmount` is required but was not set" }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable(), + .toImmutable(), + additionalProperties.toImmutable(), ) } @@ -4113,8 +4113,8 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable(), + .toImmutable(), + additionalProperties.toImmutable(), ) } @@ -4280,7 +4280,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4435,7 +4435,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4564,7 +4564,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4867,7 +4867,7 @@ constructor( "`matrixWithAllocationConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5044,14 +5044,14 @@ constructor( fun build(): MatrixWithAllocationConfig = MatrixWithAllocationConfig( checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toUnmodifiable(), + .toImmutable(), checkNotNull(defaultUnitAmount) { "`defaultUnitAmount` is required but was not set" }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toUnmodifiable(), + .toImmutable(), checkNotNull(allocation) { "`allocation` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5134,8 +5134,8 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable(), + .toImmutable(), + additionalProperties.toImmutable(), ) } @@ -5302,7 +5302,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5457,7 +5457,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5586,7 +5586,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5881,7 +5881,7 @@ constructor( checkNotNull(modelType) { "`modelType` is required but was not set" }, checkNotNull(tieredConfig) { "`tieredConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6070,9 +6070,8 @@ constructor( fun build(): TieredConfig = TieredConfig( - checkNotNull(tiers) { "`tiers` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + checkNotNull(tiers) { "`tiers` is required but was not set" }.toImmutable(), + additionalProperties.toImmutable() ) } @@ -6153,7 +6152,7 @@ constructor( checkNotNull(firstUnit) { "`firstUnit` is required but was not set" }, lastUnit, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6268,7 +6267,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6423,7 +6422,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6552,7 +6551,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -6849,7 +6848,7 @@ constructor( "`tieredBpsConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7043,9 +7042,8 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - checkNotNull(tiers) { "`tiers` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + checkNotNull(tiers) { "`tiers` is required but was not set" }.toImmutable(), + additionalProperties.toImmutable() ) } @@ -7144,7 +7142,7 @@ constructor( maximumAmount, checkNotNull(bps) { "`bps` is required but was not set" }, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7259,7 +7257,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7414,7 +7412,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7543,7 +7541,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -7835,7 +7833,7 @@ constructor( checkNotNull(modelType) { "`modelType` is required but was not set" }, checkNotNull(bpsConfig) { "`bpsConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7906,7 +7904,7 @@ constructor( BpsConfig( checkNotNull(bps) { "`bps` is required but was not set" }, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8132,7 +8130,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8287,7 +8285,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8416,7 +8414,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -8711,7 +8709,7 @@ constructor( checkNotNull(modelType) { "`modelType` is required but was not set" }, checkNotNull(bulkBpsConfig) { "`bulkBpsConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8774,9 +8772,8 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - checkNotNull(tiers) { "`tiers` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + checkNotNull(tiers) { "`tiers` is required but was not set" }.toImmutable(), + additionalProperties.toImmutable() ) } @@ -8860,7 +8857,7 @@ constructor( maximumAmount, checkNotNull(bps) { "`bps` is required but was not set" }, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9107,7 +9104,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9262,7 +9259,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9391,7 +9388,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -9683,7 +9680,7 @@ constructor( checkNotNull(modelType) { "`modelType` is required but was not set" }, checkNotNull(bulkConfig) { "`bulkConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9740,9 +9737,8 @@ constructor( fun build(): BulkConfig = BulkConfig( - checkNotNull(tiers) { "`tiers` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + checkNotNull(tiers) { "`tiers` is required but was not set" }.toImmutable(), + additionalProperties.toImmutable() ) } @@ -9814,7 +9810,7 @@ constructor( Tier( maximumUnits, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10061,7 +10057,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10216,7 +10212,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10345,7 +10341,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -10648,7 +10644,7 @@ constructor( "`thresholdTotalAmountConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10828,7 +10824,7 @@ constructor( } fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -10921,7 +10917,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11076,7 +11072,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11205,7 +11201,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -11505,7 +11501,7 @@ constructor( "`tieredPackageConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11684,7 +11680,7 @@ constructor( } fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) + TieredPackageConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -11777,7 +11773,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11932,7 +11928,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12061,7 +12057,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -12361,7 +12357,7 @@ constructor( "`groupedTieredConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12489,7 +12485,7 @@ constructor( } fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toUnmodifiable()) + GroupedTieredConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -12633,7 +12629,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12788,7 +12784,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12917,7 +12913,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -13219,7 +13215,7 @@ constructor( "`tieredWithMinimumConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13398,7 +13394,7 @@ constructor( } fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -13491,7 +13487,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13646,7 +13642,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13775,7 +13771,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -14078,7 +14074,7 @@ constructor( "`packageWithAllocationConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14259,7 +14255,7 @@ constructor( } fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + PackageWithAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -14352,7 +14348,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14507,7 +14503,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14636,7 +14632,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -14941,7 +14937,7 @@ constructor( "`tieredPackageWithMinimumConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15123,7 +15119,7 @@ constructor( } fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15216,7 +15212,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15371,7 +15367,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15500,7 +15496,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15801,7 +15797,7 @@ constructor( "`unitWithPercentConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15980,7 +15976,7 @@ constructor( } fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) + UnitWithPercentConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16073,7 +16069,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16228,7 +16224,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16357,7 +16353,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16660,7 +16656,7 @@ constructor( "`tieredWithProrationConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16840,7 +16836,7 @@ constructor( } fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + TieredWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16933,7 +16929,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17088,7 +17084,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17217,7 +17213,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17519,7 +17515,7 @@ constructor( "`unitWithProrationConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17698,7 +17694,7 @@ constructor( } fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) + UnitWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17791,7 +17787,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17946,7 +17942,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18075,7 +18071,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18377,7 +18373,7 @@ constructor( "`groupedAllocationConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18505,7 +18501,7 @@ constructor( } fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + GroupedAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18649,7 +18645,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18804,7 +18800,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18933,7 +18929,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19241,7 +19237,7 @@ constructor( "`groupedWithProratedMinimumConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19371,7 +19367,7 @@ constructor( } fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19517,7 +19513,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19672,7 +19668,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19801,7 +19797,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20106,7 +20102,7 @@ constructor( "`groupedWithMeteredMinimumConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20236,7 +20232,7 @@ constructor( } fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20382,7 +20378,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20537,7 +20533,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20666,7 +20662,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20969,7 +20965,7 @@ constructor( "`matrixWithDisplayNameConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21098,7 +21094,7 @@ constructor( } fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toUnmodifiable()) + MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -21243,7 +21239,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21398,7 +21394,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21527,7 +21523,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -21829,7 +21825,7 @@ constructor( "`bulkWithProrationConfig` is required but was not set" }, checkNotNull(currency) { "`currency` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21876,7 +21872,7 @@ constructor( } fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toUnmodifiable()) + BulkWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22101,7 +22097,7 @@ constructor( BillingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22256,7 +22252,7 @@ constructor( InvoicingCycleConfiguration( checkNotNull(duration) { "`duration` is required but was not set" }, checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22385,7 +22381,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 6f978d4f8..47489f4dc 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.util.Objects @@ -198,8 +198,8 @@ constructor( customerId, externalCustomerId, filter, - groupingKeys?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + groupingKeys?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -384,10 +384,10 @@ constructor( customerId, externalCustomerId, filter, - if (groupingKeys.size == 0) null else groupingKeys.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (groupingKeys.size == 0) null else groupingKeys.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 d7378306e..08c9d18a8 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,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.util.Objects @JsonDeserialize(builder = PriceEvaluateResponse.Builder::class) @@ -78,10 +78,7 @@ private constructor( } fun build(): PriceEvaluateResponse = - PriceEvaluateResponse( - data.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) + PriceEvaluateResponse(data.map { it.toImmutable() }, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 9d1bc9537..9c0b208c4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -115,8 +115,8 @@ constructor( fun build(): PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams( checkNotNull(externalPriceId) { "`externalPriceId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 ab68c70a2..b441c1e4d 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -104,7 +104,7 @@ constructor( } fun build(): PriceExternalPriceIdUpdateBody = - PriceExternalPriceIdUpdateBody(metadata, additionalProperties.toUnmodifiable()) + PriceExternalPriceIdUpdateBody(metadata, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -244,9 +244,9 @@ constructor( PriceExternalPriceIdUpdateParams( checkNotNull(externalPriceId) { "`externalPriceId` is required but was not set" }, metadata, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -296,7 +296,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 327221db5..aed0e2112 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): PriceFetchParams = PriceFetchParams( checkNotNull(priceId) { "`priceId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 a2bce112c..495c31635 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.PriceService import java.util.Objects import java.util.Optional @@ -176,7 +176,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 1012ce95c..6ba88b22b 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.PriceServiceAsync import java.util.Objects import java.util.Optional @@ -179,7 +179,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 1c3185140..8e9502674 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -26,7 +26,7 @@ constructor( this.cursor?.let { params.put("cursor", listOf(it.toString())) } this.limit?.let { params.put("limit", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -126,8 +126,8 @@ constructor( PriceListParams( cursor, limit, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 c8a9e814c..dadfa548c 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -103,7 +103,7 @@ constructor( } fun build(): PriceUpdateBody = - PriceUpdateBody(metadata, additionalProperties.toUnmodifiable()) + PriceUpdateBody(metadata, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -240,9 +240,9 @@ constructor( PriceUpdateParams( checkNotNull(priceId) { "`priceId` is required but was not set" }, metadata, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -292,7 +292,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 10240c47a..8f7cbaff0 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -802,7 +802,7 @@ private constructor( status, trialInfo, activePlanPhaseOrder, - fixedFeeQuantitySchedule.map { it.toUnmodifiable() }, + fixedFeeQuantitySchedule.map { it.toImmutable() }, defaultInvoiceMemo, autoCollection, netTerms, @@ -810,12 +810,12 @@ private constructor( billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, - priceIntervals.map { it.toUnmodifiable() }, - adjustmentIntervals.map { it.toUnmodifiable() }, - discountIntervals.map { it.toUnmodifiable() }, - minimumIntervals.map { it.toUnmodifiable() }, - maximumIntervals.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -968,8 +968,8 @@ private constructor( adjustment, startDate, endDate, - appliesToPriceIntervalIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1366,11 +1366,11 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, adjustmentType, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1599,11 +1599,11 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, adjustmentType, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1828,11 +1828,11 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, adjustmentType, usageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2074,12 +2074,12 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, adjustmentType, minimumAmount, itemId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2302,11 +2302,11 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, adjustmentType, maximumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2558,7 +2558,7 @@ private constructor( day, month, year, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2949,9 +2949,9 @@ private constructor( amountDiscount, startDate, endDate, - appliesToPriceIds.map { it.toUnmodifiable() }, - appliesToPriceIntervalIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -3216,9 +3216,9 @@ private constructor( percentageDiscount, startDate, endDate, - appliesToPriceIds.map { it.toUnmodifiable() }, - appliesToPriceIntervalIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -3488,9 +3488,9 @@ private constructor( usageDiscount, startDate, endDate, - appliesToPriceIds.map { it.toUnmodifiable() }, - appliesToPriceIntervalIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -3681,7 +3681,7 @@ private constructor( startDate, endDate, quantity, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3879,10 +3879,10 @@ private constructor( MaximumInterval( startDate, endDate, - appliesToPriceIds.map { it.toUnmodifiable() }, - appliesToPriceIntervalIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, maximumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3961,7 +3961,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4157,10 +4157,10 @@ private constructor( MinimumInterval( startDate, endDate, - appliesToPriceIds.map { it.toUnmodifiable() }, - appliesToPriceIntervalIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, minimumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5393,10 +5393,10 @@ private constructor( endDate, price, billingCycleDay, - fixedFeeQuantityTransitions.map { it.toUnmodifiable() }, + fixedFeeQuantityTransitions.map { it.toImmutable() }, currentBillingPeriodStartDate, currentBillingPeriodEndDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5500,7 +5500,7 @@ private constructor( priceId, effectiveDate, quantity, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5645,7 +5645,7 @@ private constructor( couponId, startDate, endDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5797,7 +5797,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toUnmodifiable()) + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 69ed23242..fe8ac2ab2 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -131,7 +131,7 @@ constructor( SubscriptionCancelBody( checkNotNull(cancelOption) { "`cancelOption` is required but was not set" }, cancellationDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -276,9 +276,9 @@ constructor( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, checkNotNull(cancelOption) { "`cancelOption` is required but was not set" }, cancellationDate, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } 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 new file mode 100644 index 000000000..dd75f7f9d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt @@ -0,0 +1,5828 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionCancelResponse.Builder::class) +@NoAutoDetect +class SubscriptionCancelResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionCancelResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionCancelResponse: SubscriptionCancelResponse) = apply { + this.metadata = subscriptionCancelResponse.metadata + this.id = subscriptionCancelResponse.id + this.customer = subscriptionCancelResponse.customer + this.plan = subscriptionCancelResponse.plan + this.startDate = subscriptionCancelResponse.startDate + this.endDate = subscriptionCancelResponse.endDate + this.createdAt = subscriptionCancelResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionCancelResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionCancelResponse.currentBillingPeriodEndDate + this.status = subscriptionCancelResponse.status + this.trialInfo = subscriptionCancelResponse.trialInfo + this.activePlanPhaseOrder = subscriptionCancelResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = subscriptionCancelResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = subscriptionCancelResponse.defaultInvoiceMemo + this.autoCollection = subscriptionCancelResponse.autoCollection + this.netTerms = subscriptionCancelResponse.netTerms + this.redeemedCoupon = subscriptionCancelResponse.redeemedCoupon + this.billingCycleDay = subscriptionCancelResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionCancelResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = subscriptionCancelResponse.invoicingThreshold + this.priceIntervals = subscriptionCancelResponse.priceIntervals + this.adjustmentIntervals = subscriptionCancelResponse.adjustmentIntervals + this.discountIntervals = subscriptionCancelResponse.discountIntervals + this.minimumIntervals = subscriptionCancelResponse.minimumIntervals + this.maximumIntervals = subscriptionCancelResponse.maximumIntervals + additionalProperties(subscriptionCancelResponse.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionCancelResponse = + SubscriptionCancelResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionCancelResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 dd760c80a..5ba4a9fbe 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -643,8 +643,8 @@ constructor( fun build(): SubscriptionCreateBody = SubscriptionCreateBody( - addAdjustments?.toUnmodifiable(), - addPrices?.toUnmodifiable(), + addAdjustments?.toImmutable(), + addPrices?.toImmutable(), alignBillingWithSubscriptionStartDate, autoCollection, awsRegion, @@ -665,14 +665,14 @@ constructor( perCreditOverageAmount, planId, planVersionNumber, - priceOverrides?.toUnmodifiable(), - removeAdjustments?.toUnmodifiable(), - removePrices?.toUnmodifiable(), - replaceAdjustments?.toUnmodifiable(), - replacePrices?.toUnmodifiable(), + priceOverrides?.toImmutable(), + removeAdjustments?.toImmutable(), + removePrices?.toImmutable(), + replaceAdjustments?.toImmutable(), + replacePrices?.toImmutable(), startDate, trialDurationDays, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1082,8 +1082,8 @@ constructor( fun build(): SubscriptionCreateParams = SubscriptionCreateParams( - if (addAdjustments.size == 0) null else addAdjustments.toUnmodifiable(), - if (addPrices.size == 0) null else addPrices.toUnmodifiable(), + if (addAdjustments.size == 0) null else addAdjustments.toImmutable(), + if (addPrices.size == 0) null else addPrices.toImmutable(), alignBillingWithSubscriptionStartDate, autoCollection, awsRegion, @@ -1104,16 +1104,16 @@ constructor( perCreditOverageAmount, planId, planVersionNumber, - if (priceOverrides.size == 0) null else priceOverrides.toUnmodifiable(), - if (removeAdjustments.size == 0) null else removeAdjustments.toUnmodifiable(), - if (removePrices.size == 0) null else removePrices.toUnmodifiable(), - if (replaceAdjustments.size == 0) null else replaceAdjustments.toUnmodifiable(), - if (replacePrices.size == 0) null else replacePrices.toUnmodifiable(), + if (priceOverrides.size == 0) null else priceOverrides.toImmutable(), + if (removeAdjustments.size == 0) null else removeAdjustments.toImmutable(), + if (removePrices.size == 0) null else removePrices.toImmutable(), + if (replaceAdjustments.size == 0) null else replaceAdjustments.toImmutable(), + if (replacePrices.size == 0) null else replacePrices.toImmutable(), startDate, trialDurationDays, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -1222,7 +1222,7 @@ constructor( startDate, endDate, planPhaseOrder, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1531,10 +1531,10 @@ constructor( fun build(): NewPercentageDiscount = NewPercentageDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1727,10 +1727,10 @@ constructor( fun build(): NewAmountDiscount = NewAmountDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1938,11 +1938,11 @@ constructor( fun build(): NewMinimum = NewMinimum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, minimumAmount, itemId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2131,10 +2131,10 @@ constructor( fun build(): NewMaximum = NewMaximum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, maximumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2390,8 +2390,8 @@ constructor( planPhaseOrder, minimumAmount, maximumAmount, - discounts?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + discounts?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -2501,7 +2501,7 @@ constructor( percentageDiscount, usageDiscount, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3980,7 +3980,7 @@ constructor( unitConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4190,7 +4190,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitConfig = - UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + UnitConfig(unitAmount, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4315,7 +4315,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4501,7 +4501,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4641,7 +4641,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5207,7 +5207,7 @@ constructor( packageConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5455,7 +5455,7 @@ constructor( PackageConfig( packageAmount, packageSize, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5581,7 +5581,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5767,7 +5767,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5907,7 +5907,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -6473,7 +6473,7 @@ constructor( matrixConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6693,10 +6693,10 @@ constructor( fun build(): MatrixConfig = MatrixConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + matrixValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -6815,8 +6815,8 @@ constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -7015,7 +7015,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7201,7 +7201,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7341,7 +7341,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -7907,7 +7907,7 @@ constructor( tieredConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8120,8 +8120,8 @@ constructor( fun build(): TieredConfig = TieredConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -8253,7 +8253,7 @@ constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8400,7 +8400,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8586,7 +8586,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8726,7 +8726,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -9296,7 +9296,7 @@ constructor( tieredBpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9517,8 +9517,8 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -9668,7 +9668,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9815,7 +9815,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10001,7 +10001,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10141,7 +10141,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -10705,7 +10705,7 @@ constructor( bpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10806,7 +10806,7 @@ constructor( BpsConfig( bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11066,7 +11066,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11252,7 +11252,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11392,7 +11392,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -11960,7 +11960,7 @@ constructor( bulkBpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12047,8 +12047,8 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -12174,7 +12174,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12455,7 +12455,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12641,7 +12641,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12781,7 +12781,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -13345,7 +13345,7 @@ constructor( bulkConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13420,8 +13420,8 @@ constructor( fun build(): BulkConfig = BulkConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -13525,7 +13525,7 @@ constructor( Tier( maximumUnits, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13806,7 +13806,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13992,7 +13992,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14132,7 +14132,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -14714,7 +14714,7 @@ constructor( thresholdTotalAmountConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14909,7 +14909,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15034,7 +15034,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15220,7 +15220,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15360,7 +15360,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15935,7 +15935,7 @@ constructor( tieredPackageConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16125,7 +16125,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) + TieredPackageConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16250,7 +16250,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16436,7 +16436,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16576,7 +16576,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17153,7 +17153,7 @@ constructor( tieredWithMinimumConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17345,7 +17345,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17470,7 +17470,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17656,7 +17656,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17796,7 +17796,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18372,7 +18372,7 @@ constructor( unitWithPercentConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18563,7 +18563,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) + UnitWithPercentConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18688,7 +18688,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18874,7 +18874,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19014,7 +19014,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19597,7 +19597,7 @@ constructor( packageWithAllocationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19791,7 +19791,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + PackageWithAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19916,7 +19916,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20102,7 +20102,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20242,7 +20242,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20820,7 +20820,7 @@ constructor( tieredWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21012,7 +21012,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + TieredWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -21137,7 +21137,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21323,7 +21323,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21463,7 +21463,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22040,7 +22040,7 @@ constructor( unitWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22232,7 +22232,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) + UnitWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22357,7 +22357,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22543,7 +22543,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22683,7 +22683,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23260,7 +23260,7 @@ constructor( groupedAllocationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23399,7 +23399,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + GroupedAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23577,7 +23577,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23763,7 +23763,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23903,7 +23903,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24500,7 +24500,7 @@ constructor( groupedWithProratedMinimumConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -24642,7 +24642,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24821,7 +24821,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25007,7 +25007,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25147,7 +25147,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -25724,7 +25724,7 @@ constructor( bulkWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25781,7 +25781,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toUnmodifiable()) + BulkWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26041,7 +26041,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26227,7 +26227,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26367,7 +26367,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26529,7 +26529,7 @@ constructor( checkNotNull(day) { "`day` is required but was not set" }, month, year, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26663,7 +26663,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26740,7 +26740,7 @@ constructor( fun build(): RemoveAdjustment = RemoveAdjustment( checkNotNull(adjustmentId) { "`adjustmentId` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -26832,7 +26832,7 @@ constructor( RemovePrice( priceId, externalPriceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26927,7 +26927,7 @@ constructor( checkNotNull(replacesAdjustmentId) { "`replacesAdjustmentId` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27236,10 +27236,10 @@ constructor( fun build(): NewPercentageDiscount = NewPercentageDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27432,10 +27432,10 @@ constructor( fun build(): NewAmountDiscount = NewAmountDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27643,11 +27643,11 @@ constructor( fun build(): NewMinimum = NewMinimum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, minimumAmount, itemId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27836,10 +27836,10 @@ constructor( fun build(): NewMaximum = NewMaximum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, maximumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -28075,8 +28075,8 @@ constructor( }, minimumAmount, maximumAmount, - discounts?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + discounts?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -28186,7 +28186,7 @@ constructor( percentageDiscount, usageDiscount, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29665,7 +29665,7 @@ constructor( unitConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29875,7 +29875,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitConfig = - UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + UnitConfig(unitAmount, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -30000,7 +30000,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -30186,7 +30186,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -30326,7 +30326,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -30892,7 +30892,7 @@ constructor( packageConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31140,7 +31140,7 @@ constructor( PackageConfig( packageAmount, packageSize, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31266,7 +31266,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31452,7 +31452,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31592,7 +31592,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -32158,7 +32158,7 @@ constructor( matrixConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32378,10 +32378,10 @@ constructor( fun build(): MatrixConfig = MatrixConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + matrixValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -32500,8 +32500,8 @@ constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -32700,7 +32700,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32886,7 +32886,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -33026,7 +33026,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -33592,7 +33592,7 @@ constructor( tieredConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -33805,8 +33805,8 @@ constructor( fun build(): TieredConfig = TieredConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -33938,7 +33938,7 @@ constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34085,7 +34085,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34271,7 +34271,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34411,7 +34411,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -34981,7 +34981,7 @@ constructor( tieredBpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -35202,8 +35202,8 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -35353,7 +35353,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -35500,7 +35500,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -35686,7 +35686,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -35826,7 +35826,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -36390,7 +36390,7 @@ constructor( bpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36491,7 +36491,7 @@ constructor( BpsConfig( bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36751,7 +36751,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36937,7 +36937,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -37077,7 +37077,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -37645,7 +37645,7 @@ constructor( bulkBpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -37732,8 +37732,8 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -37859,7 +37859,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38140,7 +38140,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38326,7 +38326,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38466,7 +38466,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -39030,7 +39030,7 @@ constructor( bulkConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39105,8 +39105,8 @@ constructor( fun build(): BulkConfig = BulkConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -39210,7 +39210,7 @@ constructor( Tier( maximumUnits, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39491,7 +39491,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39677,7 +39677,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39817,7 +39817,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -40399,7 +40399,7 @@ constructor( thresholdTotalAmountConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -40594,7 +40594,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -40719,7 +40719,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -40905,7 +40905,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41045,7 +41045,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -41620,7 +41620,7 @@ constructor( tieredPackageConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41810,7 +41810,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) + TieredPackageConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -41935,7 +41935,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -42121,7 +42121,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -42261,7 +42261,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -42838,7 +42838,7 @@ constructor( tieredWithMinimumConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -43030,7 +43030,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -43155,7 +43155,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -43341,7 +43341,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -43481,7 +43481,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -44057,7 +44057,7 @@ constructor( unitWithPercentConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -44248,7 +44248,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) + UnitWithPercentConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -44373,7 +44373,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -44559,7 +44559,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -44699,7 +44699,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -45282,7 +45282,7 @@ constructor( packageWithAllocationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -45476,7 +45476,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + PackageWithAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -45601,7 +45601,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -45787,7 +45787,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -45927,7 +45927,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -46505,7 +46505,7 @@ constructor( tieredWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -46697,7 +46697,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + TieredWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -46822,7 +46822,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -47008,7 +47008,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -47148,7 +47148,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -47725,7 +47725,7 @@ constructor( unitWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -47917,7 +47917,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) + UnitWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -48042,7 +48042,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -48228,7 +48228,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -48368,7 +48368,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -48945,7 +48945,7 @@ constructor( groupedAllocationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -49084,7 +49084,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + GroupedAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -49262,7 +49262,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -49448,7 +49448,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -49588,7 +49588,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -50185,7 +50185,7 @@ constructor( groupedWithProratedMinimumConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -50327,7 +50327,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -50506,7 +50506,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -50692,7 +50692,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -50832,7 +50832,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -51409,7 +51409,7 @@ constructor( bulkWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -51466,7 +51466,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toUnmodifiable()) + BulkWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -51726,7 +51726,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -51912,7 +51912,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -52052,7 +52052,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } 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 new file mode 100644 index 000000000..93d488db6 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt @@ -0,0 +1,5828 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionCreateResponse.Builder::class) +@NoAutoDetect +class SubscriptionCreateResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionCreateResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionCreateResponse: SubscriptionCreateResponse) = apply { + this.metadata = subscriptionCreateResponse.metadata + this.id = subscriptionCreateResponse.id + this.customer = subscriptionCreateResponse.customer + this.plan = subscriptionCreateResponse.plan + this.startDate = subscriptionCreateResponse.startDate + this.endDate = subscriptionCreateResponse.endDate + this.createdAt = subscriptionCreateResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionCreateResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionCreateResponse.currentBillingPeriodEndDate + this.status = subscriptionCreateResponse.status + this.trialInfo = subscriptionCreateResponse.trialInfo + this.activePlanPhaseOrder = subscriptionCreateResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = subscriptionCreateResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = subscriptionCreateResponse.defaultInvoiceMemo + this.autoCollection = subscriptionCreateResponse.autoCollection + this.netTerms = subscriptionCreateResponse.netTerms + this.redeemedCoupon = subscriptionCreateResponse.redeemedCoupon + this.billingCycleDay = subscriptionCreateResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionCreateResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = subscriptionCreateResponse.invoicingThreshold + this.priceIntervals = subscriptionCreateResponse.priceIntervals + this.adjustmentIntervals = subscriptionCreateResponse.adjustmentIntervals + this.discountIntervals = subscriptionCreateResponse.discountIntervals + this.minimumIntervals = subscriptionCreateResponse.minimumIntervals + this.maximumIntervals = subscriptionCreateResponse.maximumIntervals + additionalProperties(subscriptionCreateResponse.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionCreateResponse = + SubscriptionCreateResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionCreateResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 3c5e51aaf..5c9c833c9 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -48,7 +48,7 @@ constructor( } this.viewMode?.let { params.put("view_mode", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -175,8 +175,8 @@ constructor( timeframeEnd, timeframeStart, viewMode, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 9e632f321..863fb6824 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,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -81,8 +81,8 @@ private constructor( fun build(): SubscriptionFetchCostsResponse = SubscriptionFetchCostsResponse( - data.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + data.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -228,8 +228,8 @@ private constructor( total, timeframeStart, timeframeEnd, - perPriceCosts.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + perPriceCosts.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1281,7 +1281,7 @@ private constructor( subtotal, total, price, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 e17a81e8f..7447db51c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -112,8 +112,8 @@ constructor( fun build(): SubscriptionFetchParams = SubscriptionFetchParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 6c583dc52..18eabd9bf 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.SubscriptionService import java.util.Objects import java.util.Optional @@ -183,7 +183,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 49b088af6..65a468a16 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.SubscriptionServiceAsync import java.util.Objects import java.util.Optional @@ -186,7 +186,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 3eac7af78..9dd38effb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.OffsetDateTime import java.time.format.DateTimeFormatter @@ -55,7 +55,7 @@ constructor( params.put("start_date[lte]", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -188,8 +188,8 @@ constructor( startDateGte, startDateLt, startDateLte, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 4539a7e72..39c5979a9 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -128,7 +128,7 @@ private constructor( endDate, createdAt, plan, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -252,7 +252,7 @@ private constructor( id, externalPlanId, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 54b18b84b..e55e6da77 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -74,7 +74,7 @@ constructor( } this.viewMode?.let { params.put("view_mode", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -247,8 +247,8 @@ constructor( timeframeEnd, timeframeStart, viewMode, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 69d504276..2aa7cb623 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.blocking.SubscriptionService import java.util.Objects import java.util.Optional @@ -180,7 +180,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 743dc0482..401cd8d42 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.services.async.SubscriptionServiceAsync import java.util.Objects import java.util.Optional @@ -183,7 +183,7 @@ private constructor( Response( data, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } 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 6b83ed891..c6968843d 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 @@ -7,7 +7,7 @@ import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -69,7 +69,7 @@ constructor( this.limit?.let { params.put("limit", listOf(it.toString())) } this.status?.let { params.put("status", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -207,12 +207,12 @@ constructor( createdAtLt, createdAtLte, cursor, - if (customerId.size == 0) null else customerId.toUnmodifiable(), + if (customerId.size == 0) null else customerId.toImmutable(), externalCustomerId, limit, status, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 443603b9c..5fd1a0fbd 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,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -161,11 +161,11 @@ constructor( fun build(): SubscriptionPriceIntervalsBody = SubscriptionPriceIntervalsBody( - add?.toUnmodifiable(), - addAdjustments?.toUnmodifiable(), - edit?.toUnmodifiable(), - editAdjustments?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + add?.toImmutable(), + addAdjustments?.toImmutable(), + edit?.toImmutable(), + editAdjustments?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -342,13 +342,13 @@ constructor( fun build(): SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, - if (add.size == 0) null else add.toUnmodifiable(), - if (addAdjustments.size == 0) null else addAdjustments.toUnmodifiable(), - if (edit.size == 0) null else edit.toUnmodifiable(), - if (editAdjustments.size == 0) null else editAdjustments.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (add.size == 0) null else add.toImmutable(), + if (addAdjustments.size == 0) null else addAdjustments.toImmutable(), + if (edit.size == 0) null else edit.toImmutable(), + if (editAdjustments.size == 0) null else editAdjustments.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -532,11 +532,11 @@ constructor( allocationPrice, checkNotNull(startDate) { "`startDate` is required but was not set" }, endDate, - fixedFeeQuantityTransitions?.toUnmodifiable(), - discounts?.toUnmodifiable(), + fixedFeeQuantityTransitions?.toImmutable(), + discounts?.toImmutable(), minimumAmount, maximumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -770,7 +770,7 @@ constructor( checkNotNull(expiresAtEndOfCadence) { "`expiresAtEndOfCadence` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1166,7 +1166,7 @@ constructor( AmountDiscountCreationParams( discountType, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1353,7 +1353,7 @@ constructor( PercentageDiscountCreationParams( discountType, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1535,7 +1535,7 @@ constructor( UsageDiscountCreationParams( discountType, usageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1806,7 +1806,7 @@ constructor( checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3344,7 +3344,7 @@ constructor( modelType, unitConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3554,7 +3554,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitConfig = - UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + UnitConfig(unitAmount, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -3679,7 +3679,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3865,7 +3865,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4005,7 +4005,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4523,7 +4523,7 @@ constructor( modelType, packageConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4771,7 +4771,7 @@ constructor( PackageConfig( packageAmount, packageSize, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4897,7 +4897,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5083,7 +5083,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5223,7 +5223,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5741,7 +5741,7 @@ constructor( modelType, matrixConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5961,10 +5961,10 @@ constructor( fun build(): MatrixConfig = MatrixConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + matrixValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -6083,8 +6083,8 @@ constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -6283,7 +6283,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6469,7 +6469,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6609,7 +6609,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -7140,7 +7140,7 @@ constructor( modelType, matrixWithAllocationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7384,11 +7384,11 @@ constructor( fun build(): MatrixWithAllocationConfig = MatrixWithAllocationConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, + matrixValues.map { it.toImmutable() }, allocation, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7507,8 +7507,8 @@ constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -7709,7 +7709,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7895,7 +7895,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8035,7 +8035,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -8553,7 +8553,7 @@ constructor( modelType, tieredConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8766,8 +8766,8 @@ constructor( fun build(): TieredConfig = TieredConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -8899,7 +8899,7 @@ constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9046,7 +9046,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9232,7 +9232,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9372,7 +9372,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -9894,7 +9894,7 @@ constructor( modelType, tieredBpsConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10115,8 +10115,8 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -10266,7 +10266,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10413,7 +10413,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10599,7 +10599,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10739,7 +10739,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -11256,7 +11256,7 @@ constructor( modelType, bpsConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11357,7 +11357,7 @@ constructor( BpsConfig( bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11617,7 +11617,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11803,7 +11803,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11943,7 +11943,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -12463,7 +12463,7 @@ constructor( modelType, bulkBpsConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12550,8 +12550,8 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -12677,7 +12677,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12958,7 +12958,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13144,7 +13144,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13284,7 +13284,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -13801,7 +13801,7 @@ constructor( modelType, bulkConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13876,8 +13876,8 @@ constructor( fun build(): BulkConfig = BulkConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -13981,7 +13981,7 @@ constructor( Tier( maximumUnits, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14262,7 +14262,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14448,7 +14448,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14588,7 +14588,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15119,7 +15119,7 @@ constructor( modelType, thresholdTotalAmountConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15314,7 +15314,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15439,7 +15439,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15625,7 +15625,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15765,7 +15765,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16290,7 +16290,7 @@ constructor( modelType, tieredPackageConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16480,7 +16480,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) + TieredPackageConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16605,7 +16605,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16791,7 +16791,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16931,7 +16931,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17456,7 +17456,7 @@ constructor( modelType, groupedTieredConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17594,7 +17594,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toUnmodifiable()) + GroupedTieredConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17771,7 +17771,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17957,7 +17957,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18097,7 +18097,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18624,7 +18624,7 @@ constructor( modelType, tieredWithMinimumConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18816,7 +18816,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18941,7 +18941,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19127,7 +19127,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19267,7 +19267,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19799,7 +19799,7 @@ constructor( modelType, packageWithAllocationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19993,7 +19993,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + PackageWithAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20118,7 +20118,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20304,7 +20304,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20444,7 +20444,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20983,7 +20983,7 @@ constructor( modelType, tieredPackageWithMinimumConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21179,7 +21179,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -21304,7 +21304,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21490,7 +21490,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21630,7 +21630,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22155,7 +22155,7 @@ constructor( modelType, unitWithPercentConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22346,7 +22346,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) + UnitWithPercentConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22471,7 +22471,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22657,7 +22657,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22797,7 +22797,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23327,7 +23327,7 @@ constructor( modelType, tieredWithProrationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23519,7 +23519,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + TieredWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23644,7 +23644,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23830,7 +23830,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23970,7 +23970,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24497,7 +24497,7 @@ constructor( modelType, unitWithProrationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -24689,7 +24689,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) + UnitWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24814,7 +24814,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25000,7 +25000,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25140,7 +25140,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -25667,7 +25667,7 @@ constructor( modelType, groupedAllocationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25806,7 +25806,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + GroupedAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -25984,7 +25984,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26170,7 +26170,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26310,7 +26310,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26856,7 +26856,7 @@ constructor( modelType, groupedWithProratedMinimumConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26998,7 +26998,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -27177,7 +27177,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27363,7 +27363,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27503,7 +27503,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -28048,7 +28048,7 @@ constructor( modelType, groupedWithMeteredMinimumConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -28190,7 +28190,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -28369,7 +28369,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -28555,7 +28555,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -28695,7 +28695,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -29227,7 +29227,7 @@ constructor( modelType, matrixWithDisplayNameConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29367,7 +29367,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toUnmodifiable()) + MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -29546,7 +29546,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29732,7 +29732,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29872,7 +29872,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -30399,7 +30399,7 @@ constructor( modelType, bulkWithProrationConfig, currency, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -30456,7 +30456,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toUnmodifiable()) + BulkWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -30716,7 +30716,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -30902,7 +30902,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31042,7 +31042,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -31196,7 +31196,7 @@ constructor( checkNotNull(adjustment) { "`adjustment` is required but was not set" }, checkNotNull(startDate) { "`startDate` is required but was not set" }, endDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31505,10 +31505,10 @@ constructor( fun build(): NewPercentageDiscount = NewPercentageDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31701,10 +31701,10 @@ constructor( fun build(): NewAmountDiscount = NewAmountDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31912,11 +31912,11 @@ constructor( fun build(): NewMinimum = NewMinimum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, minimumAmount, itemId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32105,10 +32105,10 @@ constructor( fun build(): NewMaximum = NewMaximum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, maximumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32586,9 +32586,9 @@ constructor( }, startDate, endDate, - fixedFeeQuantityTransitions?.toUnmodifiable(), + fixedFeeQuantityTransitions?.toImmutable(), billingCycleDay, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32785,7 +32785,7 @@ constructor( checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -33047,7 +33047,7 @@ constructor( }, startDate, endDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 new file mode 100644 index 000000000..e3c9eb72c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt @@ -0,0 +1,5830 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionPriceIntervalsResponse.Builder::class) +@NoAutoDetect +class SubscriptionPriceIntervalsResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionPriceIntervalsResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionPriceIntervalsResponse: SubscriptionPriceIntervalsResponse) = + apply { + this.metadata = subscriptionPriceIntervalsResponse.metadata + this.id = subscriptionPriceIntervalsResponse.id + this.customer = subscriptionPriceIntervalsResponse.customer + this.plan = subscriptionPriceIntervalsResponse.plan + this.startDate = subscriptionPriceIntervalsResponse.startDate + this.endDate = subscriptionPriceIntervalsResponse.endDate + this.createdAt = subscriptionPriceIntervalsResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionPriceIntervalsResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionPriceIntervalsResponse.currentBillingPeriodEndDate + this.status = subscriptionPriceIntervalsResponse.status + this.trialInfo = subscriptionPriceIntervalsResponse.trialInfo + this.activePlanPhaseOrder = subscriptionPriceIntervalsResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = + subscriptionPriceIntervalsResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = subscriptionPriceIntervalsResponse.defaultInvoiceMemo + this.autoCollection = subscriptionPriceIntervalsResponse.autoCollection + this.netTerms = subscriptionPriceIntervalsResponse.netTerms + this.redeemedCoupon = subscriptionPriceIntervalsResponse.redeemedCoupon + this.billingCycleDay = subscriptionPriceIntervalsResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionPriceIntervalsResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = subscriptionPriceIntervalsResponse.invoicingThreshold + this.priceIntervals = subscriptionPriceIntervalsResponse.priceIntervals + this.adjustmentIntervals = subscriptionPriceIntervalsResponse.adjustmentIntervals + this.discountIntervals = subscriptionPriceIntervalsResponse.discountIntervals + this.minimumIntervals = subscriptionPriceIntervalsResponse.minimumIntervals + this.maximumIntervals = subscriptionPriceIntervalsResponse.maximumIntervals + additionalProperties(subscriptionPriceIntervalsResponse.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionPriceIntervalsResponse = + SubscriptionPriceIntervalsResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionPriceIntervalsResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 c38089eba..d8a67f306 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -588,8 +588,8 @@ constructor( fun build(): SubscriptionSchedulePlanChangeBody = SubscriptionSchedulePlanChangeBody( checkNotNull(changeOption) { "`changeOption` is required but was not set" }, - addAdjustments?.toUnmodifiable(), - addPrices?.toUnmodifiable(), + addAdjustments?.toImmutable(), + addPrices?.toImmutable(), alignBillingWithPlanChangeDate, autoCollection, billingCycleAlignment, @@ -604,13 +604,13 @@ constructor( perCreditOverageAmount, planId, planVersionNumber, - priceOverrides?.toUnmodifiable(), - removeAdjustments?.toUnmodifiable(), - removePrices?.toUnmodifiable(), - replaceAdjustments?.toUnmodifiable(), - replacePrices?.toUnmodifiable(), + priceOverrides?.toImmutable(), + removeAdjustments?.toImmutable(), + removePrices?.toImmutable(), + replaceAdjustments?.toImmutable(), + replacePrices?.toImmutable(), trialDurationDays, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1008,8 +1008,8 @@ constructor( SubscriptionSchedulePlanChangeParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, checkNotNull(changeOption) { "`changeOption` is required but was not set" }, - if (addAdjustments.size == 0) null else addAdjustments.toUnmodifiable(), - if (addPrices.size == 0) null else addPrices.toUnmodifiable(), + if (addAdjustments.size == 0) null else addAdjustments.toImmutable(), + if (addPrices.size == 0) null else addPrices.toImmutable(), alignBillingWithPlanChangeDate, autoCollection, billingCycleAlignment, @@ -1024,15 +1024,15 @@ constructor( perCreditOverageAmount, planId, planVersionNumber, - if (priceOverrides.size == 0) null else priceOverrides.toUnmodifiable(), - if (removeAdjustments.size == 0) null else removeAdjustments.toUnmodifiable(), - if (removePrices.size == 0) null else removePrices.toUnmodifiable(), - if (replaceAdjustments.size == 0) null else replaceAdjustments.toUnmodifiable(), - if (replacePrices.size == 0) null else replacePrices.toUnmodifiable(), + if (priceOverrides.size == 0) null else priceOverrides.toImmutable(), + if (removeAdjustments.size == 0) null else removeAdjustments.toImmutable(), + if (removePrices.size == 0) null else removePrices.toImmutable(), + if (replaceAdjustments.size == 0) null else replaceAdjustments.toImmutable(), + if (replacePrices.size == 0) null else replacePrices.toImmutable(), trialDurationDays, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -1205,7 +1205,7 @@ constructor( startDate, endDate, planPhaseOrder, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1514,10 +1514,10 @@ constructor( fun build(): NewPercentageDiscount = NewPercentageDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1710,10 +1710,10 @@ constructor( fun build(): NewAmountDiscount = NewAmountDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1921,11 +1921,11 @@ constructor( fun build(): NewMinimum = NewMinimum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, minimumAmount, itemId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2114,10 +2114,10 @@ constructor( fun build(): NewMaximum = NewMaximum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, maximumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2373,8 +2373,8 @@ constructor( planPhaseOrder, minimumAmount, maximumAmount, - discounts?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + discounts?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -2484,7 +2484,7 @@ constructor( percentageDiscount, usageDiscount, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3963,7 +3963,7 @@ constructor( unitConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4173,7 +4173,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitConfig = - UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + UnitConfig(unitAmount, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4298,7 +4298,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4484,7 +4484,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4624,7 +4624,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -5190,7 +5190,7 @@ constructor( packageConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5438,7 +5438,7 @@ constructor( PackageConfig( packageAmount, packageSize, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5564,7 +5564,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5750,7 +5750,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -5890,7 +5890,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -6456,7 +6456,7 @@ constructor( matrixConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -6676,10 +6676,10 @@ constructor( fun build(): MatrixConfig = MatrixConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + matrixValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -6798,8 +6798,8 @@ constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -6998,7 +6998,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7184,7 +7184,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -7324,7 +7324,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -7890,7 +7890,7 @@ constructor( tieredConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8103,8 +8103,8 @@ constructor( fun build(): TieredConfig = TieredConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -8236,7 +8236,7 @@ constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8383,7 +8383,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8569,7 +8569,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -8709,7 +8709,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -9279,7 +9279,7 @@ constructor( tieredBpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9500,8 +9500,8 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -9651,7 +9651,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9798,7 +9798,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -9984,7 +9984,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10124,7 +10124,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -10688,7 +10688,7 @@ constructor( bpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -10789,7 +10789,7 @@ constructor( BpsConfig( bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11049,7 +11049,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11235,7 +11235,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -11375,7 +11375,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -11943,7 +11943,7 @@ constructor( bulkBpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12030,8 +12030,8 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -12157,7 +12157,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12438,7 +12438,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12624,7 +12624,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -12764,7 +12764,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -13328,7 +13328,7 @@ constructor( bulkConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13403,8 +13403,8 @@ constructor( fun build(): BulkConfig = BulkConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -13508,7 +13508,7 @@ constructor( Tier( maximumUnits, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13789,7 +13789,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -13975,7 +13975,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14115,7 +14115,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -14697,7 +14697,7 @@ constructor( thresholdTotalAmountConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -14892,7 +14892,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15017,7 +15017,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15203,7 +15203,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -15343,7 +15343,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -15918,7 +15918,7 @@ constructor( tieredPackageConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16108,7 +16108,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) + TieredPackageConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -16233,7 +16233,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16419,7 +16419,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -16559,7 +16559,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17136,7 +17136,7 @@ constructor( tieredWithMinimumConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17328,7 +17328,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -17453,7 +17453,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17639,7 +17639,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -17779,7 +17779,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18355,7 +18355,7 @@ constructor( unitWithPercentConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18546,7 +18546,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) + UnitWithPercentConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -18671,7 +18671,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18857,7 +18857,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -18997,7 +18997,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19580,7 +19580,7 @@ constructor( packageWithAllocationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -19774,7 +19774,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + PackageWithAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -19899,7 +19899,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20085,7 +20085,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20225,7 +20225,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -20803,7 +20803,7 @@ constructor( tieredWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -20995,7 +20995,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + TieredWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -21120,7 +21120,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21306,7 +21306,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -21446,7 +21446,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22023,7 +22023,7 @@ constructor( unitWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22215,7 +22215,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) + UnitWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -22340,7 +22340,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22526,7 +22526,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -22666,7 +22666,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23243,7 +23243,7 @@ constructor( groupedAllocationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23382,7 +23382,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + GroupedAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -23560,7 +23560,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23746,7 +23746,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -23886,7 +23886,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24483,7 +24483,7 @@ constructor( groupedWithProratedMinimumConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -24625,7 +24625,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -24804,7 +24804,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -24990,7 +24990,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25130,7 +25130,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -25707,7 +25707,7 @@ constructor( bulkWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -25764,7 +25764,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toUnmodifiable()) + BulkWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26024,7 +26024,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26210,7 +26210,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26350,7 +26350,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -26533,7 +26533,7 @@ constructor( fun build(): RemoveAdjustment = RemoveAdjustment( checkNotNull(adjustmentId) { "`adjustmentId` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -26625,7 +26625,7 @@ constructor( RemovePrice( priceId, externalPriceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -26720,7 +26720,7 @@ constructor( checkNotNull(replacesAdjustmentId) { "`replacesAdjustmentId` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27029,10 +27029,10 @@ constructor( fun build(): NewPercentageDiscount = NewPercentageDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, percentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27225,10 +27225,10 @@ constructor( fun build(): NewAmountDiscount = NewAmountDiscount( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27436,11 +27436,11 @@ constructor( fun build(): NewMinimum = NewMinimum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, minimumAmount, itemId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27629,10 +27629,10 @@ constructor( fun build(): NewMaximum = NewMaximum( - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, adjustmentType, maximumAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -27868,8 +27868,8 @@ constructor( }, minimumAmount, maximumAmount, - discounts?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + discounts?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -27979,7 +27979,7 @@ constructor( percentageDiscount, usageDiscount, amountDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29458,7 +29458,7 @@ constructor( unitConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29668,7 +29668,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitConfig = - UnitConfig(unitAmount, additionalProperties.toUnmodifiable()) + UnitConfig(unitAmount, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -29793,7 +29793,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -29979,7 +29979,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -30119,7 +30119,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -30685,7 +30685,7 @@ constructor( packageConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -30933,7 +30933,7 @@ constructor( PackageConfig( packageAmount, packageSize, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31059,7 +31059,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31245,7 +31245,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -31385,7 +31385,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -31951,7 +31951,7 @@ constructor( matrixConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32171,10 +32171,10 @@ constructor( fun build(): MatrixConfig = MatrixConfig( - dimensions.map { it.toUnmodifiable() }, + dimensions.map { it.toImmutable() }, defaultUnitAmount, - matrixValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + matrixValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -32293,8 +32293,8 @@ constructor( fun build(): MatrixValue = MatrixValue( unitAmount, - dimensionValues.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + dimensionValues.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -32493,7 +32493,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32679,7 +32679,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -32819,7 +32819,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -33385,7 +33385,7 @@ constructor( tieredConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -33598,8 +33598,8 @@ constructor( fun build(): TieredConfig = TieredConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -33731,7 +33731,7 @@ constructor( firstUnit, lastUnit, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -33878,7 +33878,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34064,7 +34064,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34204,7 +34204,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -34774,7 +34774,7 @@ constructor( tieredBpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -34995,8 +34995,8 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -35146,7 +35146,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -35293,7 +35293,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -35479,7 +35479,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -35619,7 +35619,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -36183,7 +36183,7 @@ constructor( bpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36284,7 +36284,7 @@ constructor( BpsConfig( bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36544,7 +36544,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36730,7 +36730,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -36870,7 +36870,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -37438,7 +37438,7 @@ constructor( bulkBpsConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -37525,8 +37525,8 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -37652,7 +37652,7 @@ constructor( maximumAmount, bps, perUnitMaximum, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -37933,7 +37933,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38119,7 +38119,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38259,7 +38259,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -38823,7 +38823,7 @@ constructor( bulkConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -38898,8 +38898,8 @@ constructor( fun build(): BulkConfig = BulkConfig( - tiers.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + tiers.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -39003,7 +39003,7 @@ constructor( Tier( maximumUnits, unitAmount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39284,7 +39284,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39470,7 +39470,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -39610,7 +39610,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -40192,7 +40192,7 @@ constructor( thresholdTotalAmountConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -40387,7 +40387,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toUnmodifiable()) + ThresholdTotalAmountConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -40512,7 +40512,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -40698,7 +40698,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -40838,7 +40838,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -41413,7 +41413,7 @@ constructor( tieredPackageConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41603,7 +41603,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toUnmodifiable()) + TieredPackageConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -41728,7 +41728,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -41914,7 +41914,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -42054,7 +42054,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -42631,7 +42631,7 @@ constructor( tieredWithMinimumConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -42823,7 +42823,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toUnmodifiable()) + TieredWithMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -42948,7 +42948,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -43134,7 +43134,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -43274,7 +43274,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -43850,7 +43850,7 @@ constructor( unitWithPercentConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -44041,7 +44041,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toUnmodifiable()) + UnitWithPercentConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -44166,7 +44166,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -44352,7 +44352,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -44492,7 +44492,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -45075,7 +45075,7 @@ constructor( packageWithAllocationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -45269,7 +45269,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toUnmodifiable()) + PackageWithAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -45394,7 +45394,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -45580,7 +45580,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -45720,7 +45720,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -46298,7 +46298,7 @@ constructor( tieredWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -46490,7 +46490,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toUnmodifiable()) + TieredWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -46615,7 +46615,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -46801,7 +46801,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -46941,7 +46941,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -47518,7 +47518,7 @@ constructor( unitWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -47710,7 +47710,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toUnmodifiable()) + UnitWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -47835,7 +47835,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -48021,7 +48021,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -48161,7 +48161,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -48738,7 +48738,7 @@ constructor( groupedAllocationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -48877,7 +48877,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toUnmodifiable()) + GroupedAllocationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -49055,7 +49055,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -49241,7 +49241,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -49381,7 +49381,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -49978,7 +49978,7 @@ constructor( groupedWithProratedMinimumConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -50120,7 +50120,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toUnmodifiable()) + GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -50299,7 +50299,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -50485,7 +50485,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -50625,7 +50625,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -51202,7 +51202,7 @@ constructor( bulkWithProrationConfig, currency, referenceId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -51259,7 +51259,7 @@ constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toUnmodifiable()) + BulkWithProrationConfig(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -51519,7 +51519,7 @@ constructor( BillingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -51705,7 +51705,7 @@ constructor( InvoicingCycleConfiguration( duration, durationUnit, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -51845,7 +51845,7 @@ constructor( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } 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 new file mode 100644 index 000000000..30513e253 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt @@ -0,0 +1,5831 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionSchedulePlanChangeResponse.Builder::class) +@NoAutoDetect +class SubscriptionSchedulePlanChangeResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionSchedulePlanChangeResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + subscriptionSchedulePlanChangeResponse: SubscriptionSchedulePlanChangeResponse + ) = apply { + this.metadata = subscriptionSchedulePlanChangeResponse.metadata + this.id = subscriptionSchedulePlanChangeResponse.id + this.customer = subscriptionSchedulePlanChangeResponse.customer + this.plan = subscriptionSchedulePlanChangeResponse.plan + this.startDate = subscriptionSchedulePlanChangeResponse.startDate + this.endDate = subscriptionSchedulePlanChangeResponse.endDate + this.createdAt = subscriptionSchedulePlanChangeResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionSchedulePlanChangeResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionSchedulePlanChangeResponse.currentBillingPeriodEndDate + this.status = subscriptionSchedulePlanChangeResponse.status + this.trialInfo = subscriptionSchedulePlanChangeResponse.trialInfo + this.activePlanPhaseOrder = subscriptionSchedulePlanChangeResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = + subscriptionSchedulePlanChangeResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = subscriptionSchedulePlanChangeResponse.defaultInvoiceMemo + this.autoCollection = subscriptionSchedulePlanChangeResponse.autoCollection + this.netTerms = subscriptionSchedulePlanChangeResponse.netTerms + this.redeemedCoupon = subscriptionSchedulePlanChangeResponse.redeemedCoupon + this.billingCycleDay = subscriptionSchedulePlanChangeResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionSchedulePlanChangeResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = subscriptionSchedulePlanChangeResponse.invoicingThreshold + this.priceIntervals = subscriptionSchedulePlanChangeResponse.priceIntervals + this.adjustmentIntervals = subscriptionSchedulePlanChangeResponse.adjustmentIntervals + this.discountIntervals = subscriptionSchedulePlanChangeResponse.discountIntervals + this.minimumIntervals = subscriptionSchedulePlanChangeResponse.minimumIntervals + this.maximumIntervals = subscriptionSchedulePlanChangeResponse.maximumIntervals + additionalProperties(subscriptionSchedulePlanChangeResponse.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionSchedulePlanChangeResponse = + SubscriptionSchedulePlanChangeResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionSchedulePlanChangeResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 adefeb42f..a7929fad5 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.time.LocalDate import java.util.Objects @@ -104,7 +104,7 @@ constructor( } fun build(): SubscriptionTriggerPhaseBody = - SubscriptionTriggerPhaseBody(effectiveDate, additionalProperties.toUnmodifiable()) + SubscriptionTriggerPhaseBody(effectiveDate, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -240,9 +240,9 @@ constructor( SubscriptionTriggerPhaseParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, effectiveDate, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 new file mode 100644 index 000000000..d85c69d29 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt @@ -0,0 +1,5830 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionTriggerPhaseResponse.Builder::class) +@NoAutoDetect +class SubscriptionTriggerPhaseResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionTriggerPhaseResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionTriggerPhaseResponse: SubscriptionTriggerPhaseResponse) = + apply { + this.metadata = subscriptionTriggerPhaseResponse.metadata + this.id = subscriptionTriggerPhaseResponse.id + this.customer = subscriptionTriggerPhaseResponse.customer + this.plan = subscriptionTriggerPhaseResponse.plan + this.startDate = subscriptionTriggerPhaseResponse.startDate + this.endDate = subscriptionTriggerPhaseResponse.endDate + this.createdAt = subscriptionTriggerPhaseResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionTriggerPhaseResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionTriggerPhaseResponse.currentBillingPeriodEndDate + this.status = subscriptionTriggerPhaseResponse.status + this.trialInfo = subscriptionTriggerPhaseResponse.trialInfo + this.activePlanPhaseOrder = subscriptionTriggerPhaseResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = + subscriptionTriggerPhaseResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = subscriptionTriggerPhaseResponse.defaultInvoiceMemo + this.autoCollection = subscriptionTriggerPhaseResponse.autoCollection + this.netTerms = subscriptionTriggerPhaseResponse.netTerms + this.redeemedCoupon = subscriptionTriggerPhaseResponse.redeemedCoupon + this.billingCycleDay = subscriptionTriggerPhaseResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionTriggerPhaseResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = subscriptionTriggerPhaseResponse.invoicingThreshold + this.priceIntervals = subscriptionTriggerPhaseResponse.priceIntervals + this.adjustmentIntervals = subscriptionTriggerPhaseResponse.adjustmentIntervals + this.discountIntervals = subscriptionTriggerPhaseResponse.discountIntervals + this.minimumIntervals = subscriptionTriggerPhaseResponse.minimumIntervals + this.maximumIntervals = subscriptionTriggerPhaseResponse.maximumIntervals + additionalProperties(subscriptionTriggerPhaseResponse.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionTriggerPhaseResponse = + SubscriptionTriggerPhaseResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionTriggerPhaseResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 1a39a1f21..0ba9d6e8b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -142,9 +142,9 @@ constructor( fun build(): SubscriptionUnscheduleCancellationParams = SubscriptionUnscheduleCancellationParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 new file mode 100644 index 000000000..d02a09e15 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt @@ -0,0 +1,5833 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionUnscheduleCancellationResponse.Builder::class) +@NoAutoDetect +class SubscriptionUnscheduleCancellationResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionUnscheduleCancellationResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + subscriptionUnscheduleCancellationResponse: SubscriptionUnscheduleCancellationResponse + ) = apply { + this.metadata = subscriptionUnscheduleCancellationResponse.metadata + this.id = subscriptionUnscheduleCancellationResponse.id + this.customer = subscriptionUnscheduleCancellationResponse.customer + this.plan = subscriptionUnscheduleCancellationResponse.plan + this.startDate = subscriptionUnscheduleCancellationResponse.startDate + this.endDate = subscriptionUnscheduleCancellationResponse.endDate + this.createdAt = subscriptionUnscheduleCancellationResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionUnscheduleCancellationResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionUnscheduleCancellationResponse.currentBillingPeriodEndDate + this.status = subscriptionUnscheduleCancellationResponse.status + this.trialInfo = subscriptionUnscheduleCancellationResponse.trialInfo + this.activePlanPhaseOrder = + subscriptionUnscheduleCancellationResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = + subscriptionUnscheduleCancellationResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = subscriptionUnscheduleCancellationResponse.defaultInvoiceMemo + this.autoCollection = subscriptionUnscheduleCancellationResponse.autoCollection + this.netTerms = subscriptionUnscheduleCancellationResponse.netTerms + this.redeemedCoupon = subscriptionUnscheduleCancellationResponse.redeemedCoupon + this.billingCycleDay = subscriptionUnscheduleCancellationResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionUnscheduleCancellationResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = subscriptionUnscheduleCancellationResponse.invoicingThreshold + this.priceIntervals = subscriptionUnscheduleCancellationResponse.priceIntervals + this.adjustmentIntervals = + subscriptionUnscheduleCancellationResponse.adjustmentIntervals + this.discountIntervals = subscriptionUnscheduleCancellationResponse.discountIntervals + this.minimumIntervals = subscriptionUnscheduleCancellationResponse.minimumIntervals + this.maximumIntervals = subscriptionUnscheduleCancellationResponse.maximumIntervals + additionalProperties(subscriptionUnscheduleCancellationResponse.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionUnscheduleCancellationResponse = + SubscriptionUnscheduleCancellationResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionUnscheduleCancellationResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 ec1e3c651..8010f29cd 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -101,7 +101,7 @@ constructor( fun build(): SubscriptionUnscheduleFixedFeeQuantityUpdatesBody = SubscriptionUnscheduleFixedFeeQuantityUpdatesBody( checkNotNull(priceId) { "`priceId` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toImmutable() ) } @@ -242,9 +242,9 @@ constructor( SubscriptionUnscheduleFixedFeeQuantityUpdatesParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, checkNotNull(priceId) { "`priceId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 new file mode 100644 index 000000000..9880cd904 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt @@ -0,0 +1,5846 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.Builder::class) +@NoAutoDetect +class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse: + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + ) = apply { + this.metadata = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.metadata + this.id = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.id + this.customer = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.customer + this.plan = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.plan + this.startDate = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.startDate + this.endDate = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.endDate + this.createdAt = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.currentBillingPeriodEndDate + this.status = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.status + this.trialInfo = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.trialInfo + this.activePlanPhaseOrder = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.defaultInvoiceMemo + this.autoCollection = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.autoCollection + this.netTerms = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.netTerms + this.redeemedCoupon = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.redeemedCoupon + this.billingCycleDay = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .billingCycleAnchorConfiguration + this.invoicingThreshold = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.invoicingThreshold + this.priceIntervals = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.priceIntervals + this.adjustmentIntervals = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.adjustmentIntervals + this.discountIntervals = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.discountIntervals + this.minimumIntervals = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.minimumIntervals + this.maximumIntervals = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.maximumIntervals + additionalProperties( + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.additionalProperties + ) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 9333f5619..4637626bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt @@ -4,7 +4,7 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -145,9 +145,9 @@ constructor( fun build(): SubscriptionUnschedulePendingPlanChangesParams = SubscriptionUnschedulePendingPlanChangesParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 new file mode 100644 index 000000000..953e7ce11 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt @@ -0,0 +1,5841 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionUnschedulePendingPlanChangesResponse.Builder::class) +@NoAutoDetect +class SubscriptionUnschedulePendingPlanChangesResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionUnschedulePendingPlanChangesResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + subscriptionUnschedulePendingPlanChangesResponse: + SubscriptionUnschedulePendingPlanChangesResponse + ) = apply { + this.metadata = subscriptionUnschedulePendingPlanChangesResponse.metadata + this.id = subscriptionUnschedulePendingPlanChangesResponse.id + this.customer = subscriptionUnschedulePendingPlanChangesResponse.customer + this.plan = subscriptionUnschedulePendingPlanChangesResponse.plan + this.startDate = subscriptionUnschedulePendingPlanChangesResponse.startDate + this.endDate = subscriptionUnschedulePendingPlanChangesResponse.endDate + this.createdAt = subscriptionUnschedulePendingPlanChangesResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionUnschedulePendingPlanChangesResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionUnschedulePendingPlanChangesResponse.currentBillingPeriodEndDate + this.status = subscriptionUnschedulePendingPlanChangesResponse.status + this.trialInfo = subscriptionUnschedulePendingPlanChangesResponse.trialInfo + this.activePlanPhaseOrder = + subscriptionUnschedulePendingPlanChangesResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = + subscriptionUnschedulePendingPlanChangesResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = + subscriptionUnschedulePendingPlanChangesResponse.defaultInvoiceMemo + this.autoCollection = subscriptionUnschedulePendingPlanChangesResponse.autoCollection + this.netTerms = subscriptionUnschedulePendingPlanChangesResponse.netTerms + this.redeemedCoupon = subscriptionUnschedulePendingPlanChangesResponse.redeemedCoupon + this.billingCycleDay = subscriptionUnschedulePendingPlanChangesResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionUnschedulePendingPlanChangesResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = + subscriptionUnschedulePendingPlanChangesResponse.invoicingThreshold + this.priceIntervals = subscriptionUnschedulePendingPlanChangesResponse.priceIntervals + this.adjustmentIntervals = + subscriptionUnschedulePendingPlanChangesResponse.adjustmentIntervals + this.discountIntervals = + subscriptionUnschedulePendingPlanChangesResponse.discountIntervals + this.minimumIntervals = + subscriptionUnschedulePendingPlanChangesResponse.minimumIntervals + this.maximumIntervals = + subscriptionUnschedulePendingPlanChangesResponse.maximumIntervals + additionalProperties( + subscriptionUnschedulePendingPlanChangesResponse.additionalProperties + ) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionUnschedulePendingPlanChangesResponse = + SubscriptionUnschedulePendingPlanChangesResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionUnschedulePendingPlanChangesResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 2f7009657..6fecabae8 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 @@ -12,7 +12,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.LocalDate @@ -170,7 +170,7 @@ constructor( checkNotNull(quantity) { "`quantity` is required but was not set" }, changeOption, effectiveDate, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -333,9 +333,9 @@ constructor( checkNotNull(quantity) { "`quantity` is required but was not set" }, changeOption, effectiveDate, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } 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 new file mode 100644 index 000000000..beb0f52d0 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt @@ -0,0 +1,5833 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionUpdateFixedFeeQuantityResponse.Builder::class) +@NoAutoDetect +class SubscriptionUpdateFixedFeeQuantityResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionUpdateFixedFeeQuantityResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + subscriptionUpdateFixedFeeQuantityResponse: SubscriptionUpdateFixedFeeQuantityResponse + ) = apply { + this.metadata = subscriptionUpdateFixedFeeQuantityResponse.metadata + this.id = subscriptionUpdateFixedFeeQuantityResponse.id + this.customer = subscriptionUpdateFixedFeeQuantityResponse.customer + this.plan = subscriptionUpdateFixedFeeQuantityResponse.plan + this.startDate = subscriptionUpdateFixedFeeQuantityResponse.startDate + this.endDate = subscriptionUpdateFixedFeeQuantityResponse.endDate + this.createdAt = subscriptionUpdateFixedFeeQuantityResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionUpdateFixedFeeQuantityResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionUpdateFixedFeeQuantityResponse.currentBillingPeriodEndDate + this.status = subscriptionUpdateFixedFeeQuantityResponse.status + this.trialInfo = subscriptionUpdateFixedFeeQuantityResponse.trialInfo + this.activePlanPhaseOrder = + subscriptionUpdateFixedFeeQuantityResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = + subscriptionUpdateFixedFeeQuantityResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = subscriptionUpdateFixedFeeQuantityResponse.defaultInvoiceMemo + this.autoCollection = subscriptionUpdateFixedFeeQuantityResponse.autoCollection + this.netTerms = subscriptionUpdateFixedFeeQuantityResponse.netTerms + this.redeemedCoupon = subscriptionUpdateFixedFeeQuantityResponse.redeemedCoupon + this.billingCycleDay = subscriptionUpdateFixedFeeQuantityResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionUpdateFixedFeeQuantityResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = subscriptionUpdateFixedFeeQuantityResponse.invoicingThreshold + this.priceIntervals = subscriptionUpdateFixedFeeQuantityResponse.priceIntervals + this.adjustmentIntervals = + subscriptionUpdateFixedFeeQuantityResponse.adjustmentIntervals + this.discountIntervals = subscriptionUpdateFixedFeeQuantityResponse.discountIntervals + this.minimumIntervals = subscriptionUpdateFixedFeeQuantityResponse.minimumIntervals + this.maximumIntervals = subscriptionUpdateFixedFeeQuantityResponse.maximumIntervals + additionalProperties(subscriptionUpdateFixedFeeQuantityResponse.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionUpdateFixedFeeQuantityResponse = + SubscriptionUpdateFixedFeeQuantityResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionUpdateFixedFeeQuantityResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 f0511112e..815437ee7 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects import java.util.Optional @@ -205,7 +205,7 @@ constructor( invoicingThreshold, metadata, netTerms, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -386,9 +386,9 @@ constructor( invoicingThreshold, metadata, netTerms, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -438,7 +438,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 1af54c5b2..3151357db 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 @@ -21,7 +21,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import com.withorb.api.models.* import java.time.OffsetDateTime @@ -142,7 +142,7 @@ constructor( SubscriptionUpdateTrialBody( checkNotNull(trialEndDate) { "`trialEndDate` is required but was not set" }, shift, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -304,9 +304,9 @@ constructor( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, checkNotNull(trialEndDate) { "`trialEndDate` is required but was not set" }, shift, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } 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 new file mode 100644 index 000000000..edda76616 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt @@ -0,0 +1,5830 @@ +// 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.getOrThrow +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 + +@JsonDeserialize(builder = SubscriptionUpdateTrialResponse.Builder::class) +@NoAutoDetect +class SubscriptionUpdateTrialResponse +private constructor( + private val metadata: JsonField, + private val id: JsonField, + private val customer: JsonField, + private val plan: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val createdAt: JsonField, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val status: JsonField, + private val trialInfo: JsonField, + private val activePlanPhaseOrder: JsonField, + private val fixedFeeQuantitySchedule: JsonField>, + private val defaultInvoiceMemo: JsonField, + private val autoCollection: JsonField, + private val netTerms: JsonField, + private val redeemedCoupon: JsonField, + private val billingCycleDay: JsonField, + private val billingCycleAnchorConfiguration: JsonField, + private val invoicingThreshold: JsonField, + private val priceIntervals: JsonField>, + private val adjustmentIntervals: JsonField>, + private val discountIntervals: JsonField>, + private val minimumIntervals: JsonField>, + private val maximumIntervals: JsonField>, + private val additionalProperties: Map, +) { + + 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 id(): String = id.getRequired("id") + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + fun customer(): Customer = customer.getRequired("customer") + + /** + * The [Plan](../guides/core-concepts.mdx#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 date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * 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") + ) + + /** + * 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") + ) + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + + /** 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")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + /** + * 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")) + + /** + * 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")) + + /** + * 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") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** + * 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 billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) for information + * on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + + /** + * The [Plan](../guides/core-concepts.mdx#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() = plan + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder() = activePlanPhaseOrder + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + + /** + * 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() = defaultInvoiceMemo + + /** + * 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() = autoCollection + + /** + * 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() = netTerms + + @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + + /** + * 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() = billingCycleDay + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold() = invoicingThreshold + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals() = adjustmentIntervals + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SubscriptionUpdateTrialResponse = apply { + if (!validated) { + metadata().validate() + id() + customer().validate() + plan().validate() + startDate() + endDate() + createdAt() + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + status() + trialInfo().validate() + activePlanPhaseOrder() + fixedFeeQuantitySchedule().forEach { it.validate() } + defaultInvoiceMemo() + autoCollection() + netTerms() + redeemedCoupon().map { it.validate() } + billingCycleDay() + billingCycleAnchorConfiguration().validate() + invoicingThreshold() + priceIntervals().forEach { it.validate() } + adjustmentIntervals().forEach { it.validate() } + discountIntervals() + minimumIntervals().forEach { it.validate() } + maximumIntervals().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var metadata: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var customer: JsonField = JsonMissing.of() + private var plan: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var trialInfo: JsonField = JsonMissing.of() + private var activePlanPhaseOrder: JsonField = JsonMissing.of() + private var fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var redeemedCoupon: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: JsonField = + JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var priceIntervals: JsonField> = JsonMissing.of() + private var adjustmentIntervals: JsonField> = JsonMissing.of() + private var discountIntervals: JsonField> = JsonMissing.of() + private var minimumIntervals: JsonField> = JsonMissing.of() + private var maximumIntervals: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionUpdateTrialResponse: SubscriptionUpdateTrialResponse) = + apply { + this.metadata = subscriptionUpdateTrialResponse.metadata + this.id = subscriptionUpdateTrialResponse.id + this.customer = subscriptionUpdateTrialResponse.customer + this.plan = subscriptionUpdateTrialResponse.plan + this.startDate = subscriptionUpdateTrialResponse.startDate + this.endDate = subscriptionUpdateTrialResponse.endDate + this.createdAt = subscriptionUpdateTrialResponse.createdAt + this.currentBillingPeriodStartDate = + subscriptionUpdateTrialResponse.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = + subscriptionUpdateTrialResponse.currentBillingPeriodEndDate + this.status = subscriptionUpdateTrialResponse.status + this.trialInfo = subscriptionUpdateTrialResponse.trialInfo + this.activePlanPhaseOrder = subscriptionUpdateTrialResponse.activePlanPhaseOrder + this.fixedFeeQuantitySchedule = + subscriptionUpdateTrialResponse.fixedFeeQuantitySchedule + this.defaultInvoiceMemo = subscriptionUpdateTrialResponse.defaultInvoiceMemo + this.autoCollection = subscriptionUpdateTrialResponse.autoCollection + this.netTerms = subscriptionUpdateTrialResponse.netTerms + this.redeemedCoupon = subscriptionUpdateTrialResponse.redeemedCoupon + this.billingCycleDay = subscriptionUpdateTrialResponse.billingCycleDay + this.billingCycleAnchorConfiguration = + subscriptionUpdateTrialResponse.billingCycleAnchorConfiguration + this.invoicingThreshold = subscriptionUpdateTrialResponse.invoicingThreshold + this.priceIntervals = subscriptionUpdateTrialResponse.priceIntervals + this.adjustmentIntervals = subscriptionUpdateTrialResponse.adjustmentIntervals + this.discountIntervals = subscriptionUpdateTrialResponse.discountIntervals + this.minimumIntervals = subscriptionUpdateTrialResponse.minimumIntervals + this.maximumIntervals = subscriptionUpdateTrialResponse.maximumIntervals + additionalProperties(subscriptionUpdateTrialResponse.additionalProperties) + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** + * 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](../guides/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](../guides/product-catalog/timezones.md) + * 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](../guides/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](../guides/product-catalog/timezones.md) + * for information on what this timezone parameter influences within Orb. + */ + @JsonProperty("customer") + @ExcludeMissing + fun customer(customer: JsonField) = apply { this.customer = customer } + + /** + * The [Plan](../guides/core-concepts.mdx#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](../guides/core-concepts.mdx#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(plan: JsonField) = apply { this.plan = plan } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + @JsonProperty("created_at") + @ExcludeMissing + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + + @JsonProperty("trial_info") + @ExcludeMissing + fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = + fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + + /** + * 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.of(defaultInvoiceMemo)) + + /** + * 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(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** + * 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.of(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. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * 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. + */ + @JsonProperty("net_terms") + @ExcludeMissing + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = + redeemedCoupon(JsonField.of(redeemedCoupon)) + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** + * 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. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + fun invoicingThreshold(invoicingThreshold: String) = + invoicingThreshold(JsonField.of(invoicingThreshold)) + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { + this.adjustmentIntervals = adjustmentIntervals + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals + } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SubscriptionUpdateTrialResponse = + SubscriptionUpdateTrialResponse( + metadata, + id, + customer, + plan, + startDate, + endDate, + createdAt, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + status, + trialInfo, + activePlanPhaseOrder, + fixedFeeQuantitySchedule.map { it.toImmutable() }, + defaultInvoiceMemo, + autoCollection, + netTerms, + redeemedCoupon, + billingCycleDay, + billingCycleAnchorConfiguration, + invoicingThreshold, + priceIntervals.map { it.toImmutable() }, + adjustmentIntervals.map { it.toImmutable() }, + discountIntervals.map { it.toImmutable() }, + minimumIntervals.map { it.toImmutable() }, + maximumIntervals.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = AdjustmentInterval.Builder::class) + @NoAutoDetect + class AdjustmentInterval + private constructor( + private val id: JsonField, + private val adjustment: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AdjustmentInterval = apply { + if (!validated) { + id() + adjustment() + startDate() + endDate() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var adjustment: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentInterval: AdjustmentInterval) = apply { + this.id = adjustmentInterval.id + this.adjustment = adjustmentInterval.adjustment + this.startDate = adjustmentInterval.startDate + this.endDate = adjustmentInterval.endDate + this.appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + additionalProperties(adjustmentInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + @JsonProperty("adjustment") + @ExcludeMissing + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AdjustmentInterval = + AdjustmentInterval( + id, + adjustment, + startDate, + endDate, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val amountDiscountAdjustment: AmountDiscountAdjustment? = null, + private val percentageDiscountAdjustment: PercentageDiscountAdjustment? = null, + private val usageDiscountAdjustment: UsageDiscountAdjustment? = null, + private val minimumAdjustment: MinimumAdjustment? = null, + private val maximumAdjustment: MaximumAdjustment? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountAdjustment(): Optional = + Optional.ofNullable(amountDiscountAdjustment) + + fun percentageDiscountAdjustment(): Optional = + Optional.ofNullable(percentageDiscountAdjustment) + + fun usageDiscountAdjustment(): Optional = + Optional.ofNullable(usageDiscountAdjustment) + + fun minimumAdjustment(): Optional = + Optional.ofNullable(minimumAdjustment) + + fun maximumAdjustment(): Optional = + Optional.ofNullable(maximumAdjustment) + + fun isAmountDiscountAdjustment(): Boolean = amountDiscountAdjustment != null + + fun isPercentageDiscountAdjustment(): Boolean = percentageDiscountAdjustment != null + + fun isUsageDiscountAdjustment(): Boolean = usageDiscountAdjustment != null + + fun isMinimumAdjustment(): Boolean = minimumAdjustment != null + + fun isMaximumAdjustment(): Boolean = maximumAdjustment != null + + fun asAmountDiscountAdjustment(): AmountDiscountAdjustment = + amountDiscountAdjustment.getOrThrow("amountDiscountAdjustment") + + fun asPercentageDiscountAdjustment(): PercentageDiscountAdjustment = + percentageDiscountAdjustment.getOrThrow("percentageDiscountAdjustment") + + fun asUsageDiscountAdjustment(): UsageDiscountAdjustment = + usageDiscountAdjustment.getOrThrow("usageDiscountAdjustment") + + fun asMinimumAdjustment(): MinimumAdjustment = + minimumAdjustment.getOrThrow("minimumAdjustment") + + fun asMaximumAdjustment(): MaximumAdjustment = + maximumAdjustment.getOrThrow("maximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountAdjustment != null -> + visitor.visitAmountDiscountAdjustment(amountDiscountAdjustment) + percentageDiscountAdjustment != null -> + visitor.visitPercentageDiscountAdjustment(percentageDiscountAdjustment) + usageDiscountAdjustment != null -> + visitor.visitUsageDiscountAdjustment(usageDiscountAdjustment) + minimumAdjustment != null -> visitor.visitMinimumAdjustment(minimumAdjustment) + maximumAdjustment != null -> visitor.visitMaximumAdjustment(maximumAdjustment) + else -> visitor.unknown(_json) + } + } + + fun validate(): Adjustment = apply { + if (!validated) { + if ( + amountDiscountAdjustment == null && + percentageDiscountAdjustment == null && + usageDiscountAdjustment == null && + minimumAdjustment == null && + maximumAdjustment == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + amountDiscountAdjustment?.validate() + percentageDiscountAdjustment?.validate() + usageDiscountAdjustment?.validate() + minimumAdjustment?.validate() + maximumAdjustment?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Adjustment && this.amountDiscountAdjustment == other.amountDiscountAdjustment && this.percentageDiscountAdjustment == other.percentageDiscountAdjustment && this.usageDiscountAdjustment == other.usageDiscountAdjustment && this.minimumAdjustment == other.minimumAdjustment && this.maximumAdjustment == other.maximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountAdjustment, percentageDiscountAdjustment, usageDiscountAdjustment, minimumAdjustment, maximumAdjustment) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountAdjustment != null -> + "Adjustment{amountDiscountAdjustment=$amountDiscountAdjustment}" + percentageDiscountAdjustment != null -> + "Adjustment{percentageDiscountAdjustment=$percentageDiscountAdjustment}" + usageDiscountAdjustment != null -> + "Adjustment{usageDiscountAdjustment=$usageDiscountAdjustment}" + minimumAdjustment != null -> "Adjustment{minimumAdjustment=$minimumAdjustment}" + maximumAdjustment != null -> "Adjustment{maximumAdjustment=$maximumAdjustment}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountAdjustment(amountDiscountAdjustment: AmountDiscountAdjustment) = + Adjustment(amountDiscountAdjustment = amountDiscountAdjustment) + + @JvmStatic + fun ofPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ) = Adjustment(percentageDiscountAdjustment = percentageDiscountAdjustment) + + @JvmStatic + fun ofUsageDiscountAdjustment(usageDiscountAdjustment: UsageDiscountAdjustment) = + Adjustment(usageDiscountAdjustment = usageDiscountAdjustment) + + @JvmStatic + fun ofMinimumAdjustment(minimumAdjustment: MinimumAdjustment) = + Adjustment(minimumAdjustment = minimumAdjustment) + + @JvmStatic + fun ofMaximumAdjustment(maximumAdjustment: MaximumAdjustment) = + Adjustment(maximumAdjustment = maximumAdjustment) + } + + interface Visitor { + + fun visitAmountDiscountAdjustment( + amountDiscountAdjustment: AmountDiscountAdjustment + ): T + + fun visitPercentageDiscountAdjustment( + percentageDiscountAdjustment: PercentageDiscountAdjustment + ): T + + fun visitUsageDiscountAdjustment( + usageDiscountAdjustment: UsageDiscountAdjustment + ): T + + fun visitMinimumAdjustment(minimumAdjustment: MinimumAdjustment): T + + fun visitMaximumAdjustment(maximumAdjustment: MaximumAdjustment): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + 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) { + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(amountDiscountAdjustment = it, _json = json) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment( + percentageDiscountAdjustment = it, + _json = json + ) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(usageDiscountAdjustment = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(minimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(maximumAdjustment = it, _json = json) + } + } + } + + return Adjustment(_json = json) + } + } + + class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountAdjustment != null -> + generator.writeObject(value.amountDiscountAdjustment) + value.percentageDiscountAdjustment != null -> + generator.writeObject(value.percentageDiscountAdjustment) + value.usageDiscountAdjustment != null -> + generator.writeObject(value.usageDiscountAdjustment) + value.minimumAdjustment != null -> + generator.writeObject(value.minimumAdjustment) + value.maximumAdjustment != null -> + generator.writeObject(value.maximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + + @JsonDeserialize(builder = AmountDiscountAdjustment.Builder::class) + @NoAutoDetect + class AmountDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val amountDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount() = amountDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + amountDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountAdjustment: AmountDiscountAdjustment) = apply { + this.appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + this.reason = amountDiscountAdjustment.reason + this.adjustmentType = amountDiscountAdjustment.adjustmentType + this.amountDiscount = amountDiscountAdjustment.amountDiscount + additionalProperties(amountDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + 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. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountAdjustment = + AmountDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + amountDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val AMOUNT_DISCOUNT = AdjustmentType(JsonField.of("amount_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + AMOUNT_DISCOUNT, + } + + enum class Value { + AMOUNT_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.amountDiscount == other.amountDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, amountDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountAdjustment.Builder::class) + @NoAutoDetect + class PercentageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val percentageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = percentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + percentageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountAdjustment: PercentageDiscountAdjustment) = + apply { + this.appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + this.reason = percentageDiscountAdjustment.reason + this.adjustmentType = percentageDiscountAdjustment.adjustmentType + this.percentageDiscount = + percentageDiscountAdjustment.percentageDiscount + additionalProperties(percentageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountAdjustment = + PercentageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + percentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val PERCENTAGE_DISCOUNT = + AdjustmentType(JsonField.of("percentage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE_DISCOUNT, + } + + enum class Value { + PERCENTAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.percentageDiscount == other.percentageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, percentageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountAdjustment.Builder::class) + @NoAutoDetect + class UsageDiscountAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val usageDiscount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * 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() = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + usageDiscount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { + this.appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + this.reason = usageDiscountAdjustment.reason + this.adjustmentType = usageDiscountAdjustment.adjustmentType + this.usageDiscount = usageDiscountAdjustment.usageDiscount + additionalProperties(usageDiscountAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountAdjustment = + UsageDiscountAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val USAGE_DISCOUNT = AdjustmentType(JsonField.of("usage_discount")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + USAGE_DISCOUNT, + } + + enum class Value { + USAGE_DISCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.usageDiscount == other.usageDiscount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, usageDiscount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumAdjustment.Builder::class) + @NoAutoDetect + class MinimumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val minimumAmount: JsonField, + private val itemId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The minimum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + minimumAmount() + itemId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var itemId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumAdjustment: MinimumAdjustment) = apply { + this.appliesToPriceIds = minimumAdjustment.appliesToPriceIds + this.reason = minimumAdjustment.reason + this.adjustmentType = minimumAdjustment.adjustmentType + this.minimumAmount = minimumAdjustment.minimumAmount + this.itemId = minimumAdjustment.itemId + additionalProperties(minimumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** 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. */ + @JsonProperty("item_id") + @ExcludeMissing + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumAdjustment = + MinimumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + minimumAmount, + itemId, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MINIMUM = AdjustmentType(JsonField.of("minimum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MINIMUM, + } + + enum class Value { + MINIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.minimumAmount == other.minimumAmount && this.itemId == other.itemId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, minimumAmount, itemId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, minimumAmount=$minimumAmount, itemId=$itemId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumAdjustment.Builder::class) + @NoAutoDetect + class MaximumAdjustment + private constructor( + private val appliesToPriceIds: JsonField>, + private val reason: JsonField, + private val adjustmentType: JsonField, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * 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 price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType() = adjustmentType + + /** + * The maximum amount to charge in a given billing period for the prices this + * adjustment applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumAdjustment = apply { + if (!validated) { + appliesToPriceIds() + reason() + adjustmentType() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var adjustmentType: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumAdjustment: MaximumAdjustment) = apply { + this.appliesToPriceIds = maximumAdjustment.appliesToPriceIds + this.reason = maximumAdjustment.reason + this.adjustmentType = maximumAdjustment.adjustmentType + this.maximumAmount = maximumAdjustment.maximumAmount + additionalProperties(maximumAdjustment.additionalProperties) + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** The reason for the adjustment. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** The reason for the adjustment. */ + @JsonProperty("reason") + @ExcludeMissing + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumAdjustment = + MaximumAdjustment( + appliesToPriceIds.map { it.toImmutable() }, + reason, + adjustmentType, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MAXIMUM = AdjustmentType(JsonField.of("maximum")) + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + enum class Known { + MAXIMUM, + } + + enum class Value { + MAXIMUM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumAdjustment && this.appliesToPriceIds == other.appliesToPriceIds && this.reason == other.reason && this.adjustmentType == other.adjustmentType && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(appliesToPriceIds, reason, adjustmentType, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumAdjustment{appliesToPriceIds=$appliesToPriceIds, reason=$reason, adjustmentType=$adjustmentType, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentInterval && this.id == other.id && this.adjustment == other.adjustment && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, adjustment, startDate, endDate, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AdjustmentInterval{id=$id, adjustment=$adjustment, startDate=$startDate, endDate=$endDate, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = BillingCycleAnchorConfiguration.Builder::class) + @NoAutoDetect + class BillingCycleAnchorConfiguration + private constructor( + private val day: JsonField, + private val month: JsonField, + private val year: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * 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() = 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() = 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() = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var day: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = + apply { + this.day = billingCycleAnchorConfiguration.day + this.month = billingCycleAnchorConfiguration.month + this.year = billingCycleAnchorConfiguration.year + additionalProperties(billingCycleAnchorConfiguration.additionalProperties) + } + + /** + * 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. + */ + @JsonProperty("day") + @ExcludeMissing + 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.of(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). + */ + @JsonProperty("month") + @ExcludeMissing + 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.of(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.). + */ + @JsonProperty("year") + @ExcludeMissing + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BillingCycleAnchorConfiguration = + BillingCycleAnchorConfiguration( + day, + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfiguration && this.day == other.day && this.month == other.month && this.year == other.year && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(day, month, year, additionalProperties) /* spotless:on */ + } + return 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 amountDiscountInterval: AmountDiscountInterval? = null, + private val percentageDiscountInterval: PercentageDiscountInterval? = null, + private val usageDiscountInterval: UsageDiscountInterval? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun amountDiscountInterval(): Optional = + Optional.ofNullable(amountDiscountInterval) + + fun percentageDiscountInterval(): Optional = + Optional.ofNullable(percentageDiscountInterval) + + fun usageDiscountInterval(): Optional = + Optional.ofNullable(usageDiscountInterval) + + fun isAmountDiscountInterval(): Boolean = amountDiscountInterval != null + + fun isPercentageDiscountInterval(): Boolean = percentageDiscountInterval != null + + fun isUsageDiscountInterval(): Boolean = usageDiscountInterval != null + + fun asAmountDiscountInterval(): AmountDiscountInterval = + amountDiscountInterval.getOrThrow("amountDiscountInterval") + + fun asPercentageDiscountInterval(): PercentageDiscountInterval = + percentageDiscountInterval.getOrThrow("percentageDiscountInterval") + + fun asUsageDiscountInterval(): UsageDiscountInterval = + usageDiscountInterval.getOrThrow("usageDiscountInterval") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountInterval != null -> + visitor.visitAmountDiscountInterval(amountDiscountInterval) + percentageDiscountInterval != null -> + visitor.visitPercentageDiscountInterval(percentageDiscountInterval) + usageDiscountInterval != null -> + visitor.visitUsageDiscountInterval(usageDiscountInterval) + else -> visitor.unknown(_json) + } + } + + fun validate(): DiscountInterval = apply { + if (!validated) { + if ( + amountDiscountInterval == null && + percentageDiscountInterval == null && + usageDiscountInterval == null + ) { + throw OrbInvalidDataException("Unknown DiscountInterval: $_json") + } + amountDiscountInterval?.validate() + percentageDiscountInterval?.validate() + usageDiscountInterval?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && this.amountDiscountInterval == other.amountDiscountInterval && this.percentageDiscountInterval == other.percentageDiscountInterval && this.usageDiscountInterval == other.usageDiscountInterval /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(amountDiscountInterval, percentageDiscountInterval, usageDiscountInterval) /* spotless:on */ + } + + override fun toString(): String { + return when { + amountDiscountInterval != null -> + "DiscountInterval{amountDiscountInterval=$amountDiscountInterval}" + percentageDiscountInterval != null -> + "DiscountInterval{percentageDiscountInterval=$percentageDiscountInterval}" + usageDiscountInterval != null -> + "DiscountInterval{usageDiscountInterval=$usageDiscountInterval}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + + companion object { + + @JvmStatic + fun ofAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval) = + DiscountInterval(amountDiscountInterval = amountDiscountInterval) + + @JvmStatic + fun ofPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ) = DiscountInterval(percentageDiscountInterval = percentageDiscountInterval) + + @JvmStatic + fun ofUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval) = + DiscountInterval(usageDiscountInterval = usageDiscountInterval) + } + + interface Visitor { + + fun visitAmountDiscountInterval(amountDiscountInterval: AmountDiscountInterval): T + + fun visitPercentageDiscountInterval( + percentageDiscountInterval: PercentageDiscountInterval + ): T + + fun visitUsageDiscountInterval(usageDiscountInterval: UsageDiscountInterval): T + + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + 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(amountDiscountInterval = it, _json = json) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountInterval = it, + _json = json + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval(usageDiscountInterval = it, _json = json) + } + } + } + + return DiscountInterval(_json = json) + } + } + + class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.amountDiscountInterval != null -> + generator.writeObject(value.amountDiscountInterval) + value.percentageDiscountInterval != null -> + generator.writeObject(value.percentageDiscountInterval) + value.usageDiscountInterval != null -> + generator.writeObject(value.usageDiscountInterval) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + + @JsonDeserialize(builder = AmountDiscountInterval.Builder::class) + @NoAutoDetect + class AmountDiscountInterval + private constructor( + private val discountType: JsonField, + private val amountDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AmountDiscountInterval = apply { + if (!validated) { + discountType() + amountDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { + this.discountType = amountDiscountInterval.discountType + this.amountDiscount = amountDiscountInterval.amountDiscount + this.startDate = amountDiscountInterval.startDate + this.endDate = amountDiscountInterval.endDate + this.appliesToPriceIds = amountDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds + additionalProperties(amountDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AmountDiscountInterval = + AmountDiscountInterval( + discountType, + amountDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AMOUNT = DiscountType(JsonField.of("amount")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + AMOUNT, + } + + enum class Value { + AMOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountInterval && this.discountType == other.discountType && this.amountDiscount == other.amountDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, amountDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AmountDiscountInterval{discountType=$discountType, amountDiscount=$amountDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = PercentageDiscountInterval.Builder::class) + @NoAutoDetect + class PercentageDiscountInterval + private constructor( + private val discountType: JsonField, + private val percentageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount() = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PercentageDiscountInterval = apply { + if (!validated) { + discountType() + percentageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { + this.discountType = percentageDiscountInterval.discountType + this.percentageDiscount = percentageDiscountInterval.percentageDiscount + this.startDate = percentageDiscountInterval.startDate + this.endDate = percentageDiscountInterval.endDate + this.appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(percentageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + 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. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PercentageDiscountInterval = + PercentageDiscountInterval( + discountType, + percentageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PERCENTAGE = DiscountType(JsonField.of("percentage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + PERCENTAGE, + } + + enum class Value { + PERCENTAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountInterval && this.discountType == other.discountType && this.percentageDiscount == other.percentageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, percentageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PercentageDiscountInterval{discountType=$discountType, percentageDiscount=$percentageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = UsageDiscountInterval.Builder::class) + @NoAutoDetect + class UsageDiscountInterval + private constructor( + private val discountType: JsonField, + private val usageDiscount: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + 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") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the discount interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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") + + @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): UsageDiscountInterval = apply { + if (!validated) { + discountType() + usageDiscount() + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var discountType: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { + this.discountType = usageDiscountInterval.discountType + this.usageDiscount = usageDiscountInterval.usageDiscount + this.startDate = usageDiscountInterval.startDate + this.endDate = usageDiscountInterval.endDate + this.appliesToPriceIds = usageDiscountInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + additionalProperties(usageDiscountInterval.additionalProperties) + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + @JsonProperty("discount_type") + @ExcludeMissing + 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 + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the discount interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): UsageDiscountInterval = + UsageDiscountInterval( + discountType, + usageDiscount, + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USAGE = DiscountType(JsonField.of("usage")) + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + enum class Known { + USAGE, + } + + enum class Value { + USAGE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountInterval && this.discountType == other.discountType && this.usageDiscount == other.usageDiscount && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(discountType, usageDiscount, startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "UsageDiscountInterval{discountType=$discountType, usageDiscount=$usageDiscount, startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(builder = FixedFeeQuantitySchedule.Builder::class) + @NoAutoDetect + class FixedFeeQuantitySchedule + private constructor( + private val priceId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun quantity(): Double = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantitySchedule = apply { + if (!validated) { + priceId() + startDate() + endDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { + this.priceId = fixedFeeQuantitySchedule.priceId + this.startDate = fixedFeeQuantitySchedule.startDate + this.endDate = fixedFeeQuantitySchedule.endDate + this.quantity = fixedFeeQuantitySchedule.quantity + additionalProperties(fixedFeeQuantitySchedule.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantitySchedule = + FixedFeeQuantitySchedule( + priceId, + startDate, + endDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantitySchedule && this.priceId == other.priceId && this.startDate == other.startDate && this.endDate == other.endDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, startDate, endDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantitySchedule{priceId=$priceId, startDate=$startDate, endDate=$endDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MaximumInterval.Builder::class) + @NoAutoDetect + class MaximumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val maximumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MaximumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + maximumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumInterval: MaximumInterval) = apply { + this.startDate = maximumInterval.startDate + this.endDate = maximumInterval.endDate + this.appliesToPriceIds = maximumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + this.maximumAmount = maximumInterval.maximumAmount + additionalProperties(maximumInterval.additionalProperties) + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MaximumInterval = + MaximumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + maximumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.maximumAmount == other.maximumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, maximumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MaximumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, 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`. + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = MinimumInterval.Builder::class) + @NoAutoDetect + class MinimumInterval + private constructor( + private val startDate: JsonField, + private val endDate: JsonField, + private val appliesToPriceIds: JsonField>, + private val appliesToPriceIntervalIds: JsonField>, + private val minimumAmount: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** 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 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. */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds() = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): MinimumInterval = apply { + if (!validated) { + startDate() + endDate() + appliesToPriceIds() + appliesToPriceIntervalIds() + minimumAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField> = JsonMissing.of() + private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumInterval: MinimumInterval) = apply { + this.startDate = minimumInterval.startDate + this.endDate = minimumInterval.endDate + this.appliesToPriceIds = minimumInterval.appliesToPriceIds + this.appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + this.minimumAmount = minimumInterval.minimumAmount + additionalProperties(minimumInterval.additionalProperties) + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** 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. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds + } + + /** 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. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = + apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + } + + /** + * 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. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): MinimumInterval = + MinimumInterval( + startDate, + endDate, + appliesToPriceIds.map { it.toImmutable() }, + appliesToPriceIntervalIds.map { it.toImmutable() }, + minimumAmount, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumInterval && this.startDate == other.startDate && this.endDate == other.endDate && this.appliesToPriceIds == other.appliesToPriceIds && this.appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && this.minimumAmount == other.minimumAmount && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(startDate, endDate, appliesToPriceIds, appliesToPriceIntervalIds, minimumAmount, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MinimumInterval{startDate=$startDate, endDate=$endDate, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, minimumAmount=$minimumAmount, 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. + */ + @JsonDeserialize(builder = PriceInterval.Builder::class) + @NoAutoDetect + class PriceInterval + private constructor( + private val id: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val price: JsonField, + private val billingCycleDay: JsonField, + private val fixedFeeQuantityTransitions: JsonField>, + private val currentBillingPeriodStartDate: JsonField, + private val currentBillingPeriodEndDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun id(): String = id.getRequired("id") + + /** + * 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") + + /** + * 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")) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(): Price = price.getRequired("price") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * 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 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 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") + ) + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") @ExcludeMissing fun _price() = price + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + + /** + * 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() = currentBillingPeriodStartDate + + /** + * 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() = currentBillingPeriodEndDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PriceInterval = apply { + if (!validated) { + id() + startDate() + endDate() + price() + billingCycleDay() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + currentBillingPeriodStartDate() + currentBillingPeriodEndDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var billingCycleDay: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of() + private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() + private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceInterval: PriceInterval) = apply { + this.id = priceInterval.id + this.startDate = priceInterval.startDate + this.endDate = priceInterval.endDate + this.price = priceInterval.price + this.billingCycleDay = priceInterval.billingCycleDay + this.fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + this.currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate + this.currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate + additionalProperties(priceInterval.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** + * 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. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + 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. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + @JsonProperty("price") + @ExcludeMissing + fun price(price: JsonField) = apply { this.price = price } + + /** 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 */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List + ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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.of(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. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun currentBillingPeriodEndDate( + currentBillingPeriodEndDate: JsonField + ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PriceInterval = + PriceInterval( + id, + startDate, + endDate, + price, + billingCycleDay, + fixedFeeQuantityTransitions.map { it.toImmutable() }, + currentBillingPeriodStartDate, + currentBillingPeriodEndDate, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = FixedFeeQuantityTransition.Builder::class) + @NoAutoDetect + class FixedFeeQuantityTransition + private constructor( + private val priceId: JsonField, + private val effectiveDate: JsonField, + private val quantity: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun priceId(): String = priceId.getRequired("price_id") + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + priceId() + effectiveDate() + quantity() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var priceId: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + this.priceId = fixedFeeQuantityTransition.priceId + this.effectiveDate = fixedFeeQuantityTransition.effectiveDate + this.quantity = fixedFeeQuantityTransition.quantity + additionalProperties(fixedFeeQuantityTransition.additionalProperties) + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + @JsonProperty("price_id") + @ExcludeMissing + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + @JsonProperty("quantity") + @ExcludeMissing + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + priceId, + effectiveDate, + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && this.priceId == other.priceId && this.effectiveDate == other.effectiveDate && this.quantity == other.quantity && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(priceId, effectiveDate, quantity, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FixedFeeQuantityTransition{priceId=$priceId, effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceInterval && this.id == other.id && this.startDate == other.startDate && this.endDate == other.endDate && this.price == other.price && this.billingCycleDay == other.billingCycleDay && this.fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, startDate, endDate, price, billingCycleDay, fixedFeeQuantityTransitions, currentBillingPeriodStartDate, currentBillingPeriodEndDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PriceInterval{id=$id, startDate=$startDate, endDate=$endDate, price=$price, billingCycleDay=$billingCycleDay, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = RedeemedCoupon.Builder::class) + @NoAutoDetect + class RedeemedCoupon + private constructor( + private val couponId: JsonField, + private val startDate: JsonField, + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + + @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RedeemedCoupon = apply { + if (!validated) { + couponId() + startDate() + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var couponId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(redeemedCoupon: RedeemedCoupon) = apply { + this.couponId = redeemedCoupon.couponId + this.startDate = redeemedCoupon.startDate + this.endDate = redeemedCoupon.endDate + additionalProperties(redeemedCoupon.additionalProperties) + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + @JsonProperty("coupon_id") + @ExcludeMissing + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + @JsonProperty("start_date") + @ExcludeMissing + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RedeemedCoupon = + RedeemedCoupon( + couponId, + startDate, + endDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RedeemedCoupon && this.couponId == other.couponId && this.startDate == other.startDate && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(couponId, startDate, endDate, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RedeemedCoupon{couponId=$couponId, startDate=$startDate, endDate=$endDate, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = Status(JsonField.of("active")) + + @JvmField val ENDED = Status(JsonField.of("ended")) + + @JvmField val UPCOMING = Status(JsonField.of("upcoming")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + enum class Value { + ACTIVE, + ENDED, + UPCOMING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = TrialInfo.Builder::class) + @NoAutoDetect + class TrialInfo + private constructor( + private val endDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): TrialInfo = apply { + if (!validated) { + endDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialInfo: TrialInfo) = apply { + this.endDate = trialInfo.endDate + additionalProperties(trialInfo.additionalProperties) + } + + fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + + @JsonProperty("end_date") + @ExcludeMissing + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialInfo && this.endDate == other.endDate && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(endDate, additionalProperties) /* spotless:on */ + } + return 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 && this.metadata == other.metadata && this.id == other.id && this.customer == other.customer && this.plan == other.plan && this.startDate == other.startDate && this.endDate == other.endDate && this.createdAt == other.createdAt && this.currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && this.currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && this.status == other.status && this.trialInfo == other.trialInfo && this.activePlanPhaseOrder == other.activePlanPhaseOrder && this.fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && this.defaultInvoiceMemo == other.defaultInvoiceMemo && this.autoCollection == other.autoCollection && this.netTerms == other.netTerms && this.redeemedCoupon == other.redeemedCoupon && this.billingCycleDay == other.billingCycleDay && this.billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && this.invoicingThreshold == other.invoicingThreshold && this.priceIntervals == other.priceIntervals && this.adjustmentIntervals == other.adjustmentIntervals && this.discountIntervals == other.discountIntervals && this.minimumIntervals == other.minimumIntervals && this.maximumIntervals == other.maximumIntervals && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, id, customer, plan, startDate, endDate, createdAt, currentBillingPeriodStartDate, currentBillingPeriodEndDate, status, trialInfo, activePlanPhaseOrder, fixedFeeQuantitySchedule, defaultInvoiceMemo, autoCollection, netTerms, redeemedCoupon, billingCycleDay, billingCycleAnchorConfiguration, invoicingThreshold, priceIntervals, adjustmentIntervals, discountIntervals, minimumIntervals, maximumIntervals, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SubscriptionUpdateTrialResponse{metadata=$metadata, id=$id, customer=$customer, plan=$plan, startDate=$startDate, endDate=$endDate, createdAt=$createdAt, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, status=$status, trialInfo=$trialInfo, activePlanPhaseOrder=$activePlanPhaseOrder, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, defaultInvoiceMemo=$defaultInvoiceMemo, autoCollection=$autoCollection, netTerms=$netTerms, redeemedCoupon=$redeemedCoupon, billingCycleDay=$billingCycleDay, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, invoicingThreshold=$invoicingThreshold, priceIntervals=$priceIntervals, adjustmentIntervals=$adjustmentIntervals, discountIntervals=$discountIntervals, minimumIntervals=$minimumIntervals, maximumIntervals=$maximumIntervals, 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 b9ebf469a..469317108 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 @@ -22,7 +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.getOrThrow -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -226,8 +226,8 @@ private constructor( fun build(): UngroupedSubscriptionUsage = UngroupedSubscriptionUsage( - data.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + data.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } @@ -328,10 +328,10 @@ private constructor( fun build(): Data = Data( - usage.map { it.toUnmodifiable() }, + usage.map { it.toImmutable() }, billableMetric, viewMode, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -417,7 +417,7 @@ private constructor( BillableMetric( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -547,7 +547,7 @@ private constructor( quantity, timeframeStart, timeframeEnd, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -756,9 +756,9 @@ private constructor( fun build(): GroupedSubscriptionUsage = GroupedSubscriptionUsage( - data.map { it.toUnmodifiable() }, + data.map { it.toImmutable() }, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -875,11 +875,11 @@ private constructor( fun build(): Data = Data( - usage.map { it.toUnmodifiable() }, + usage.map { it.toImmutable() }, billableMetric, metricGroup, viewMode, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -965,7 +965,7 @@ private constructor( BillableMetric( id, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1077,7 +1077,7 @@ private constructor( MetricGroup( propertyKey, propertyValue, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1207,7 +1207,7 @@ private constructor( quantity, timeframeStart, timeframeEnd, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 1b5863d20..210e73742 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,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.util.Objects @JsonDeserialize(builder = Subscriptions.Builder::class) @@ -99,9 +99,9 @@ private constructor( fun build(): Subscriptions = Subscriptions( - data.map { it.toUnmodifiable() }, + data.map { it.toImmutable() }, paginationMetadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 7e93d5090..4e77157c7 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 @@ -3,7 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.models.* import java.util.Objects @@ -97,8 +97,8 @@ constructor( fun build(): TopLevelPingParams = TopLevelPingParams( - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable() + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable() ) } } 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 664ef789c..29acd38af 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 @@ -11,7 +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.toUnmodifiable +import com.withorb.api.core.toImmutable import java.util.Objects @JsonDeserialize(builder = TopLevelPingResponse.Builder::class) @@ -78,7 +78,7 @@ private constructor( } fun build(): TopLevelPingResponse = - TopLevelPingResponse(response, additionalProperties.toUnmodifiable()) + TopLevelPingResponse(response, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 94e055444..88b2f2d7c 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 @@ -13,7 +13,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.toUnmodifiable +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -183,11 +183,11 @@ private constructor( fun build(): TrialDiscount = TrialDiscount( discountType, - appliesToPriceIds.map { it.toUnmodifiable() }, + appliesToPriceIds.map { it.toImmutable() }, reason, trialAmountDiscount, trialPercentageDiscount, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/Handlers.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/Handlers.kt deleted file mode 100644 index a648be415..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/Handlers.kt +++ /dev/null @@ -1,186 +0,0 @@ -@file:JvmName("Handlers") - -package com.withorb.api.services - -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ListMultimap -import com.withorb.api.core.http.BinaryResponseContent -import com.withorb.api.core.http.HttpResponse -import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.errors.BadRequestException -import com.withorb.api.errors.InternalServerException -import com.withorb.api.errors.NotFoundException -import com.withorb.api.errors.OrbError -import com.withorb.api.errors.OrbException -import com.withorb.api.errors.PermissionDeniedException -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 java.io.ByteArrayInputStream -import java.io.InputStream -import java.io.OutputStream -import java.util.Optional - -@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandler - -private object EmptyHandler : Handler { - override fun handle(response: HttpResponse): Void? = null -} - -@JvmSynthetic internal fun stringHandler(): Handler = StringHandler - -@JvmSynthetic internal fun binaryHandler(): Handler = BinaryHandler - -private object StringHandler : Handler { - override fun handle(response: HttpResponse): String { - return response.body().readBytes().toString(Charsets.UTF_8) - } -} - -private object BinaryHandler : Handler { - override fun handle(response: HttpResponse): BinaryResponseContent { - return object : BinaryResponseContent { - override fun contentType(): Optional = - Optional.ofNullable(response.headers().get("Content-Type").firstOrNull()) - - override fun body(): InputStream = response.body() - - override fun close() = response.close() - - override fun writeTo(outputStream: OutputStream) { - response.body().copyTo(outputStream) - } - } - } -} - -@JvmSynthetic -internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler { - return object : Handler { - override fun handle(response: HttpResponse): T { - try { - return jsonMapper.readValue(response.body(), jacksonTypeRef()) - } catch (e: Exception) { - throw OrbException("Error reading response", e) - } - } - } -} - -@JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { - val handler = jsonHandler(jsonMapper) - - return object : Handler { - override fun handle(response: HttpResponse): OrbError { - try { - return handler.handle(response) - } catch (e: Exception) { - return OrbError.builder().build() - } - } - } -} - -@JvmSynthetic -internal fun Handler.withErrorHandler(errorHandler: Handler): Handler { - return object : Handler { - override fun handle(response: HttpResponse): T { - when (val statusCode = response.statusCode()) { - in 200..299 -> { - return this@withErrorHandler.handle(response) - } - 400 -> { - val buffered = response.buffered() - throw BadRequestException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 401 -> { - val buffered = response.buffered() - throw UnauthorizedException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 403 -> { - val buffered = response.buffered() - throw PermissionDeniedException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 404 -> { - val buffered = response.buffered() - throw NotFoundException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 422 -> { - val buffered = response.buffered() - throw UnprocessableEntityException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 429 -> { - val buffered = response.buffered() - throw RateLimitException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - in 500..599 -> { - val buffered = response.buffered() - throw InternalServerException( - statusCode, - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - else -> { - val buffered = response.buffered() - throw UnexpectedStatusCodeException( - statusCode, - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - } - } - } -} - -private fun HttpResponse.buffered(): HttpResponse { - val body = body().readBytes() - - return object : HttpResponse { - override fun statusCode(): Int { - return this@buffered.statusCode() - } - - override fun headers(): ListMultimap { - return this@buffered.headers() - } - - override fun body(): InputStream { - return ByteArrayInputStream(body) - } - - override fun close() { - this@buffered.close() - } - } -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/HttpRequestBodies.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/HttpRequestBodies.kt deleted file mode 100644 index eca245acc..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/HttpRequestBodies.kt +++ /dev/null @@ -1,114 +0,0 @@ -@file:JvmName("HttpRequestBodies") - -package com.withorb.api.services - -import com.fasterxml.jackson.databind.json.JsonMapper -import com.withorb.api.core.Enum -import com.withorb.api.core.JsonValue -import com.withorb.api.core.MultipartFormValue -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/services/async/SubscriptionServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsync.kt index a81993ec0..36a1f333e 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 @@ -7,7 +7,9 @@ package com.withorb.api.services.async import com.withorb.api.core.RequestOptions import com.withorb.api.models.Subscription 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 @@ -17,14 +19,22 @@ import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionListPageAsync import com.withorb.api.models.SubscriptionListParams 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 @@ -269,7 +279,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`, @@ -355,7 +365,7 @@ interface SubscriptionServiceAsync { fun cancel( params: SubscriptionCancelParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to fetch a [Subscription](../guides/concepts#subscription) given an @@ -649,7 +659,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 @@ -818,7 +828,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). @@ -827,7 +837,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. @@ -840,7 +850,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. @@ -852,7 +862,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. @@ -861,7 +871,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. @@ -881,7 +891,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 @@ -905,5 +915,5 @@ interface SubscriptionServiceAsync { fun updateTrial( params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): 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 84a27c746..6046f6bde 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 @@ -14,7 +14,9 @@ import com.withorb.api.core.json import com.withorb.api.errors.OrbError import com.withorb.api.models.Subscription 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 @@ -24,14 +26,22 @@ import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionListPageAsync import com.withorb.api.models.SubscriptionListParams 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 @@ -42,8 +52,9 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * A subscription represents the purchase of a plan by a customer. The customer is identified by @@ -283,7 +294,7 @@ constructor( override fun create( params: SubscriptionCreateParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -379,8 +390,9 @@ constructor( } } - private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to cancel an existing subscription. It returns the serialized @@ -439,7 +451,7 @@ constructor( override fun cancel( params: SubscriptionCancelParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -774,8 +786,9 @@ constructor( } } - private val priceIntervalsHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val priceIntervalsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint is used to add and edit subscription @@ -847,7 +860,7 @@ constructor( override fun priceIntervals( params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -870,8 +883,9 @@ constructor( } } - private val schedulePlanChangeHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val schedulePlanChangeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to change an existing subscription's plan. It returns the @@ -1039,7 +1053,7 @@ constructor( override fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1062,8 +1076,9 @@ constructor( } } - private val triggerPhaseHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val triggerPhaseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * Manually trigger a phase, effective the given date (or the current time, if not specified). @@ -1071,7 +1086,7 @@ constructor( override fun triggerPhase( params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1094,8 +1109,9 @@ constructor( } } - private val unscheduleCancellationHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val unscheduleCancellationHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to unschedule any pending cancellations for a subscription. @@ -1107,7 +1123,7 @@ constructor( override fun unscheduleCancellation( params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1130,8 +1146,10 @@ constructor( } } - private val unscheduleFixedFeeQuantityUpdatesHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val unscheduleFixedFeeQuantityUpdatesHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. @@ -1142,7 +1160,7 @@ constructor( override fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1169,8 +1187,10 @@ constructor( } } - private val unschedulePendingPlanChangesHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val unschedulePendingPlanChangesHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to unschedule any pending plan changes on an existing subscription. @@ -1178,7 +1198,7 @@ constructor( override fun unschedulePendingPlanChanges( params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1205,8 +1225,9 @@ constructor( } } - private val updateFixedFeeQuantityHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateFixedFeeQuantityHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to update the quantity for a fixed fee. @@ -1225,7 +1246,7 @@ constructor( override fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1252,8 +1273,9 @@ constructor( } } - private val updateTrialHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateTrialHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint is used to update the trial end date for a subscription. The new trial end date @@ -1276,7 +1298,7 @@ constructor( override fun updateTrial( params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionService.kt index a1ce4f4ef..918e7f76b 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 @@ -7,7 +7,9 @@ package com.withorb.api.services.blocking import com.withorb.api.core.RequestOptions import com.withorb.api.models.Subscription 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 @@ -17,14 +19,22 @@ import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionListPage import com.withorb.api.models.SubscriptionListParams 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 { @@ -268,7 +278,7 @@ interface SubscriptionService { fun create( params: SubscriptionCreateParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionCreateResponse /** * This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, @@ -354,7 +364,7 @@ interface SubscriptionService { fun cancel( params: SubscriptionCancelParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionCancelResponse /** * This endpoint is used to fetch a [Subscription](../guides/concepts#subscription) given an @@ -648,7 +658,7 @@ interface SubscriptionService { fun priceIntervals( params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionPriceIntervalsResponse /** * This endpoint can be used to change an existing subscription's plan. It returns the @@ -817,7 +827,7 @@ interface SubscriptionService { fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionSchedulePlanChangeResponse /** * Manually trigger a phase, effective the given date (or the current time, if not specified). @@ -826,7 +836,7 @@ interface SubscriptionService { fun triggerPhase( params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionTriggerPhaseResponse /** * This endpoint can be used to unschedule any pending cancellations for a subscription. @@ -839,7 +849,7 @@ interface SubscriptionService { fun unscheduleCancellation( params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionUnscheduleCancellationResponse /** * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. @@ -851,7 +861,7 @@ interface SubscriptionService { fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse /** * This endpoint can be used to unschedule any pending plan changes on an existing subscription. @@ -860,7 +870,7 @@ interface SubscriptionService { fun unschedulePendingPlanChanges( params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionUnschedulePendingPlanChangesResponse /** * This endpoint can be used to update the quantity for a fixed fee. @@ -880,7 +890,7 @@ interface SubscriptionService { fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionUpdateFixedFeeQuantityResponse /** * This endpoint is used to update the trial end date for a subscription. The new trial end date @@ -904,5 +914,5 @@ interface SubscriptionService { fun updateTrial( params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions = RequestOptions.none() - ): Subscription + ): SubscriptionUpdateTrialResponse } 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 c4b7b3614..d5aefb46e 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 @@ -14,7 +14,9 @@ import com.withorb.api.core.json import com.withorb.api.errors.OrbError import com.withorb.api.models.Subscription 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 @@ -24,14 +26,22 @@ import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionListPage import com.withorb.api.models.SubscriptionListParams 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 @@ -41,8 +51,9 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * A subscription represents the purchase of a plan by a customer. The customer is identified by @@ -282,7 +293,7 @@ constructor( override fun create( params: SubscriptionCreateParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionCreateResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -375,8 +386,9 @@ constructor( } } - private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to cancel an existing subscription. It returns the serialized @@ -435,7 +447,7 @@ constructor( override fun cancel( params: SubscriptionCancelParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionCancelResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -765,8 +777,9 @@ constructor( } } - private val priceIntervalsHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val priceIntervalsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint is used to add and edit subscription @@ -838,7 +851,7 @@ constructor( override fun priceIntervals( params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionPriceIntervalsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -860,8 +873,9 @@ constructor( } } - private val schedulePlanChangeHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val schedulePlanChangeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to change an existing subscription's plan. It returns the @@ -1029,7 +1043,7 @@ constructor( override fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionSchedulePlanChangeResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1051,8 +1065,9 @@ constructor( } } - private val triggerPhaseHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val triggerPhaseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * Manually trigger a phase, effective the given date (or the current time, if not specified). @@ -1060,7 +1075,7 @@ constructor( override fun triggerPhase( params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionTriggerPhaseResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1082,8 +1097,9 @@ constructor( } } - private val unscheduleCancellationHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val unscheduleCancellationHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to unschedule any pending cancellations for a subscription. @@ -1095,7 +1111,7 @@ constructor( override fun unscheduleCancellation( params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionUnscheduleCancellationResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1117,8 +1133,10 @@ constructor( } } - private val unscheduleFixedFeeQuantityUpdatesHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val unscheduleFixedFeeQuantityUpdatesHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. @@ -1129,7 +1147,7 @@ constructor( override fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1155,8 +1173,10 @@ constructor( } } - private val unschedulePendingPlanChangesHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val unschedulePendingPlanChangesHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to unschedule any pending plan changes on an existing subscription. @@ -1164,7 +1184,7 @@ constructor( override fun unschedulePendingPlanChanges( params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionUnschedulePendingPlanChangesResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1190,8 +1210,9 @@ constructor( } } - private val updateFixedFeeQuantityHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateFixedFeeQuantityHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint can be used to update the quantity for a fixed fee. @@ -1210,7 +1231,7 @@ constructor( override fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionUpdateFixedFeeQuantityResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -1236,8 +1257,9 @@ constructor( } } - private val updateTrialHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateTrialHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * This endpoint is used to update the trial end date for a subscription. The new trial end date @@ -1260,7 +1282,7 @@ constructor( override fun updateTrial( params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions - ): Subscription { + ): SubscriptionUpdateTrialResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/SerializerTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/SerializerTest.kt index 9fb0ef445..ee098af5d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/SerializerTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/SerializerTest.kt @@ -92,7 +92,7 @@ internal class SerializerTest { fun build(): ClassWithBooleanFieldPrefixedWithIs = ClassWithBooleanFieldPrefixedWithIs( isActive, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt new file mode 100644 index 000000000..342717def --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt @@ -0,0 +1,969 @@ +// 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 SubscriptionCancelResponseTest { + + @Test + fun createSubscriptionCancelResponse() { + val subscriptionCancelResponse = + SubscriptionCancelResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionCancelResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionCancelResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionCancelResponse.BillingCycleAnchorConfiguration.builder() + .day(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionCancelResponse.DiscountInterval.ofAmountDiscountInterval( + SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .discountType( + SubscriptionCancelResponse.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionCancelResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionCancelResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .metadata(SubscriptionCancelResponse.Metadata.builder().build()) + .minimumIntervals( + listOf( + SubscriptionCancelResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionCancelResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionCancelResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .redeemedCoupon( + SubscriptionCancelResponse.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(SubscriptionCancelResponse.Status.ACTIVE) + .trialInfo( + SubscriptionCancelResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + assertThat(subscriptionCancelResponse).isNotNull + assertThat(subscriptionCancelResponse.id()).isEqualTo("id") + assertThat(subscriptionCancelResponse.activePlanPhaseOrder()).contains(123L) + assertThat(subscriptionCancelResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionCancelResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionCancelResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCancelResponse.autoCollection()).contains(true) + assertThat(subscriptionCancelResponse.billingCycleAnchorConfiguration()) + .isEqualTo( + SubscriptionCancelResponse.BillingCycleAnchorConfiguration.builder() + .day(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionCancelResponse.billingCycleDay()).isEqualTo(31L) + assertThat(subscriptionCancelResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCancelResponse.currentBillingPeriodEndDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCancelResponse.currentBillingPeriodStartDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCancelResponse.customer()) + .isEqualTo( + Customer.builder() + .id("id") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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(subscriptionCancelResponse.defaultInvoiceMemo()).contains("default_invoice_memo") + assertThat(subscriptionCancelResponse.discountIntervals()) + .containsExactly( + SubscriptionCancelResponse.DiscountInterval.ofAmountDiscountInterval( + SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval.builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .discountType( + SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + assertThat(subscriptionCancelResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCancelResponse.fixedFeeQuantitySchedule()) + .containsExactly( + SubscriptionCancelResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCancelResponse.invoicingThreshold()).contains("invoicing_threshold") + assertThat(subscriptionCancelResponse.maximumIntervals()) + .containsExactly( + SubscriptionCancelResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCancelResponse.metadata()) + .isEqualTo(SubscriptionCancelResponse.Metadata.builder().build()) + assertThat(subscriptionCancelResponse.minimumIntervals()) + .containsExactly( + SubscriptionCancelResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCancelResponse.netTerms()).isEqualTo(123L) + assertThat(subscriptionCancelResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionCancelResponse.priceIntervals()) + .containsExactly( + SubscriptionCancelResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionCancelResponse.PriceInterval.FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCancelResponse.redeemedCoupon()) + .contains( + SubscriptionCancelResponse.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(subscriptionCancelResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCancelResponse.status()) + .isEqualTo(SubscriptionCancelResponse.Status.ACTIVE) + assertThat(subscriptionCancelResponse.trialInfo()) + .isEqualTo( + SubscriptionCancelResponse.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/SubscriptionCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt new file mode 100644 index 000000000..25cceb4c7 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt @@ -0,0 +1,969 @@ +// 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 SubscriptionCreateResponseTest { + + @Test + fun createSubscriptionCreateResponse() { + val subscriptionCreateResponse = + SubscriptionCreateResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionCreateResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionCreateResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + SubscriptionCreateResponse.BillingCycleAnchorConfiguration.builder() + .day(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionCreateResponse.DiscountInterval.ofAmountDiscountInterval( + SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .discountType( + SubscriptionCreateResponse.DiscountInterval + .AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionCreateResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionCreateResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .metadata(SubscriptionCreateResponse.Metadata.builder().build()) + .minimumIntervals( + listOf( + SubscriptionCreateResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionCreateResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionCreateResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .redeemedCoupon( + SubscriptionCreateResponse.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(SubscriptionCreateResponse.Status.ACTIVE) + .trialInfo( + SubscriptionCreateResponse.TrialInfo.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + assertThat(subscriptionCreateResponse).isNotNull + assertThat(subscriptionCreateResponse.id()).isEqualTo("id") + assertThat(subscriptionCreateResponse.activePlanPhaseOrder()).contains(123L) + assertThat(subscriptionCreateResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionCreateResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionCreateResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCreateResponse.autoCollection()).contains(true) + assertThat(subscriptionCreateResponse.billingCycleAnchorConfiguration()) + .isEqualTo( + SubscriptionCreateResponse.BillingCycleAnchorConfiguration.builder() + .day(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionCreateResponse.billingCycleDay()).isEqualTo(31L) + assertThat(subscriptionCreateResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCreateResponse.currentBillingPeriodEndDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCreateResponse.currentBillingPeriodStartDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCreateResponse.customer()) + .isEqualTo( + Customer.builder() + .id("id") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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(subscriptionCreateResponse.defaultInvoiceMemo()).contains("default_invoice_memo") + assertThat(subscriptionCreateResponse.discountIntervals()) + .containsExactly( + SubscriptionCreateResponse.DiscountInterval.ofAmountDiscountInterval( + SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval.builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .discountType( + SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval + .DiscountType + .AMOUNT + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + assertThat(subscriptionCreateResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCreateResponse.fixedFeeQuantitySchedule()) + .containsExactly( + SubscriptionCreateResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCreateResponse.invoicingThreshold()).contains("invoicing_threshold") + assertThat(subscriptionCreateResponse.maximumIntervals()) + .containsExactly( + SubscriptionCreateResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCreateResponse.metadata()) + .isEqualTo(SubscriptionCreateResponse.Metadata.builder().build()) + assertThat(subscriptionCreateResponse.minimumIntervals()) + .containsExactly( + SubscriptionCreateResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCreateResponse.netTerms()).isEqualTo(123L) + assertThat(subscriptionCreateResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionCreateResponse.priceIntervals()) + .containsExactly( + SubscriptionCreateResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionCreateResponse.PriceInterval.FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionCreateResponse.redeemedCoupon()) + .contains( + SubscriptionCreateResponse.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(subscriptionCreateResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(subscriptionCreateResponse.status()) + .isEqualTo(SubscriptionCreateResponse.Status.ACTIVE) + assertThat(subscriptionCreateResponse.trialInfo()) + .isEqualTo( + SubscriptionCreateResponse.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/SubscriptionPriceIntervalsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt new file mode 100644 index 000000000..07a97c284 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt @@ -0,0 +1,979 @@ +// 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 SubscriptionPriceIntervalsResponseTest { + + @Test + fun createSubscriptionPriceIntervalsResponse() { + val subscriptionPriceIntervalsResponse = + SubscriptionPriceIntervalsResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionPriceIntervalsResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionPriceIntervalsResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionPriceIntervalsResponse.DiscountInterval + .ofAmountDiscountInterval( + SubscriptionPriceIntervalsResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionPriceIntervalsResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionPriceIntervalsResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + .minimumIntervals( + listOf( + SubscriptionPriceIntervalsResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionPriceIntervalsResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionPriceIntervalsResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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(123L) + assertThat(subscriptionPriceIntervalsResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionPriceIntervalsResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionPriceIntervalsResponse.billingCycleDay()).isEqualTo(31L) + 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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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.ofAmountDiscountInterval( + SubscriptionPriceIntervalsResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionPriceIntervalsResponse.invoicingThreshold()) + .contains("invoicing_threshold") + assertThat(subscriptionPriceIntervalsResponse.maximumIntervals()) + .containsExactly( + SubscriptionPriceIntervalsResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + assertThat(subscriptionPriceIntervalsResponse.minimumIntervals()) + .containsExactly( + SubscriptionPriceIntervalsResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(123L) + assertThat(subscriptionPriceIntervalsResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionPriceIntervalsResponse.priceIntervals()) + .containsExactly( + SubscriptionPriceIntervalsResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionPriceIntervalsResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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/SubscriptionSchedulePlanChangeResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt new file mode 100644 index 000000000..540b5e1a9 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt @@ -0,0 +1,979 @@ +// 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 SubscriptionSchedulePlanChangeResponseTest { + + @Test + fun createSubscriptionSchedulePlanChangeResponse() { + val subscriptionSchedulePlanChangeResponse = + SubscriptionSchedulePlanChangeResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionSchedulePlanChangeResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionSchedulePlanChangeResponse.DiscountInterval + .ofAmountDiscountInterval( + SubscriptionSchedulePlanChangeResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionSchedulePlanChangeResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionSchedulePlanChangeResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + .minimumIntervals( + listOf( + SubscriptionSchedulePlanChangeResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionSchedulePlanChangeResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionSchedulePlanChangeResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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(123L) + assertThat(subscriptionSchedulePlanChangeResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionSchedulePlanChangeResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionSchedulePlanChangeResponse.billingCycleDay()).isEqualTo(31L) + 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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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.ofAmountDiscountInterval( + SubscriptionSchedulePlanChangeResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionSchedulePlanChangeResponse.invoicingThreshold()) + .contains("invoicing_threshold") + assertThat(subscriptionSchedulePlanChangeResponse.maximumIntervals()) + .containsExactly( + SubscriptionSchedulePlanChangeResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + assertThat(subscriptionSchedulePlanChangeResponse.minimumIntervals()) + .containsExactly( + SubscriptionSchedulePlanChangeResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(123L) + assertThat(subscriptionSchedulePlanChangeResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionSchedulePlanChangeResponse.priceIntervals()) + .containsExactly( + SubscriptionSchedulePlanChangeResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionSchedulePlanChangeResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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/SubscriptionTriggerPhaseResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt new file mode 100644 index 000000000..c018ace95 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt @@ -0,0 +1,975 @@ +// 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 SubscriptionTriggerPhaseResponseTest { + + @Test + fun createSubscriptionTriggerPhaseResponse() { + val subscriptionTriggerPhaseResponse = + SubscriptionTriggerPhaseResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionTriggerPhaseResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionTriggerPhaseResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionTriggerPhaseResponse.DiscountInterval.ofAmountDiscountInterval( + SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionTriggerPhaseResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionTriggerPhaseResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + .minimumIntervals( + listOf( + SubscriptionTriggerPhaseResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionTriggerPhaseResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionTriggerPhaseResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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(123L) + assertThat(subscriptionTriggerPhaseResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionTriggerPhaseResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionTriggerPhaseResponse.billingCycleDay()).isEqualTo(31L) + 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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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.ofAmountDiscountInterval( + SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionTriggerPhaseResponse.invoicingThreshold()) + .contains("invoicing_threshold") + assertThat(subscriptionTriggerPhaseResponse.maximumIntervals()) + .containsExactly( + SubscriptionTriggerPhaseResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + assertThat(subscriptionTriggerPhaseResponse.minimumIntervals()) + .containsExactly( + SubscriptionTriggerPhaseResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(123L) + assertThat(subscriptionTriggerPhaseResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionTriggerPhaseResponse.priceIntervals()) + .containsExactly( + SubscriptionTriggerPhaseResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionTriggerPhaseResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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 new file mode 100644 index 000000000..ab81049c6 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt @@ -0,0 +1,987 @@ +// 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 SubscriptionUnscheduleCancellationResponseTest { + + @Test + fun createSubscriptionUnscheduleCancellationResponse() { + val subscriptionUnscheduleCancellationResponse = + SubscriptionUnscheduleCancellationResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval + .Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUnscheduleCancellationResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUnscheduleCancellationResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionUnscheduleCancellationResponse.DiscountInterval + .ofAmountDiscountInterval( + SubscriptionUnscheduleCancellationResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionUnscheduleCancellationResponse.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionUnscheduleCancellationResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + .minimumIntervals( + listOf( + SubscriptionUnscheduleCancellationResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionUnscheduleCancellationResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUnscheduleCancellationResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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(123L) + assertThat(subscriptionUnscheduleCancellationResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUnscheduleCancellationResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUnscheduleCancellationResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionUnscheduleCancellationResponse.billingCycleDay()).isEqualTo(31L) + 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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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 + .ofAmountDiscountInterval( + SubscriptionUnscheduleCancellationResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionUnscheduleCancellationResponse.invoicingThreshold()) + .contains("invoicing_threshold") + assertThat(subscriptionUnscheduleCancellationResponse.maximumIntervals()) + .containsExactly( + SubscriptionUnscheduleCancellationResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + assertThat(subscriptionUnscheduleCancellationResponse.minimumIntervals()) + .containsExactly( + SubscriptionUnscheduleCancellationResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(123L) + assertThat(subscriptionUnscheduleCancellationResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionUnscheduleCancellationResponse.priceIntervals()) + .containsExactly( + SubscriptionUnscheduleCancellationResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUnscheduleCancellationResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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 new file mode 100644 index 000000000..fd6195ed4 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt @@ -0,0 +1,1018 @@ +// 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 SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { + + @Test + fun createSubscriptionUnscheduleFixedFeeQuantityUpdatesResponse() { + val subscriptionUnscheduleFixedFeeQuantityUpdatesResponse = + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .AdjustmentInterval + .Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval + .ofAmountDiscountInterval( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MaximumInterval + .builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build() + ) + .minimumIntervals( + listOf( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MinimumInterval + .builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval + .builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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(123L) + assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval + .Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.billingCycleDay()) + .isEqualTo(31L) + 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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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 + .ofAmountDiscountInterval( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.invoicingThreshold()) + .contains("invoicing_threshold") + assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.maximumIntervals()) + .containsExactly( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build() + ) + assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.minimumIntervals()) + .containsExactly( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(123L) + assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.priceIntervals()) + .containsExactly( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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 new file mode 100644 index 000000000..dbcb000fd --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt @@ -0,0 +1,997 @@ +// 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 SubscriptionUnschedulePendingPlanChangesResponseTest { + + @Test + fun createSubscriptionUnschedulePendingPlanChangesResponse() { + val subscriptionUnschedulePendingPlanChangesResponse = + SubscriptionUnschedulePendingPlanChangesResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval + .builder() + .id("id") + .adjustment( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval + .Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUnschedulePendingPlanChangesResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUnschedulePendingPlanChangesResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval + .ofAmountDiscountInterval( + SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionUnschedulePendingPlanChangesResponse.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionUnschedulePendingPlanChangesResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build() + ) + .minimumIntervals( + listOf( + SubscriptionUnschedulePendingPlanChangesResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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(123L) + assertThat(subscriptionUnschedulePendingPlanChangesResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval + .Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUnschedulePendingPlanChangesResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionUnschedulePendingPlanChangesResponse.billingCycleDay()) + .isEqualTo(31L) + 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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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 + .ofAmountDiscountInterval( + SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionUnschedulePendingPlanChangesResponse.invoicingThreshold()) + .contains("invoicing_threshold") + assertThat(subscriptionUnschedulePendingPlanChangesResponse.maximumIntervals()) + .containsExactly( + SubscriptionUnschedulePendingPlanChangesResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + assertThat(subscriptionUnschedulePendingPlanChangesResponse.minimumIntervals()) + .containsExactly( + SubscriptionUnschedulePendingPlanChangesResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(123L) + assertThat(subscriptionUnschedulePendingPlanChangesResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionUnschedulePendingPlanChangesResponse.priceIntervals()) + .containsExactly( + SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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 new file mode 100644 index 000000000..03f4e3633 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt @@ -0,0 +1,987 @@ +// 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 SubscriptionUpdateFixedFeeQuantityResponseTest { + + @Test + fun createSubscriptionUpdateFixedFeeQuantityResponse() { + val subscriptionUpdateFixedFeeQuantityResponse = + SubscriptionUpdateFixedFeeQuantityResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval + .Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUpdateFixedFeeQuantityResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUpdateFixedFeeQuantityResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval + .ofAmountDiscountInterval( + SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionUpdateFixedFeeQuantityResponse.FixedFeeQuantitySchedule + .builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionUpdateFixedFeeQuantityResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + .minimumIntervals( + listOf( + SubscriptionUpdateFixedFeeQuantityResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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(123L) + assertThat(subscriptionUpdateFixedFeeQuantityResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUpdateFixedFeeQuantityResponse + .AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionUpdateFixedFeeQuantityResponse.billingCycleDay()).isEqualTo(31L) + 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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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 + .ofAmountDiscountInterval( + SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval + .AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionUpdateFixedFeeQuantityResponse.invoicingThreshold()) + .contains("invoicing_threshold") + assertThat(subscriptionUpdateFixedFeeQuantityResponse.maximumIntervals()) + .containsExactly( + SubscriptionUpdateFixedFeeQuantityResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + assertThat(subscriptionUpdateFixedFeeQuantityResponse.minimumIntervals()) + .containsExactly( + SubscriptionUpdateFixedFeeQuantityResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(123L) + assertThat(subscriptionUpdateFixedFeeQuantityResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionUpdateFixedFeeQuantityResponse.priceIntervals()) + .containsExactly( + SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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 new file mode 100644 index 000000000..974780fc6 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt @@ -0,0 +1,974 @@ +// 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 SubscriptionUpdateTrialResponseTest { + + @Test + fun createSubscriptionUpdateTrialResponse() { + val subscriptionUpdateTrialResponse = + SubscriptionUpdateTrialResponse.builder() + .id("id") + .activePlanPhaseOrder(123L) + .adjustmentIntervals( + listOf( + SubscriptionUpdateTrialResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUpdateTrialResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUpdateTrialResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + .billingCycleDay(31L) + .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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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") + .discountIntervals( + listOf( + SubscriptionUpdateTrialResponse.DiscountInterval.ofAmountDiscountInterval( + SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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")) + .fixedFeeQuantitySchedule( + listOf( + SubscriptionUpdateTrialResponse.FixedFeeQuantitySchedule.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .invoicingThreshold("invoicing_threshold") + .maximumIntervals( + listOf( + SubscriptionUpdateTrialResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + .minimumIntervals( + listOf( + SubscriptionUpdateTrialResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("string")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .netTerms(123L) + .plan( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + .priceIntervals( + listOf( + SubscriptionUpdateTrialResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUpdateTrialResponse.PriceInterval + .FixedFeeQuantityTransition + .builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder() + .id("id") + .build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder() + .id("id") + .name("name") + .build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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(123L) + assertThat(subscriptionUpdateTrialResponse.adjustmentIntervals()) + .containsExactly( + SubscriptionUpdateTrialResponse.AdjustmentInterval.builder() + .id("id") + .adjustment( + SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment + .ofAmountDiscountAdjustment( + SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment + .AmountDiscountAdjustment + .builder() + .adjustmentType( + SubscriptionUpdateTrialResponse.AdjustmentInterval + .Adjustment + .AmountDiscountAdjustment + .AdjustmentType + .AMOUNT_DISCOUNT + ) + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .reason("reason") + .build() + ) + ) + .appliesToPriceIntervalIds(listOf("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(31L) + .month(12L) + .year(123L) + .build() + ) + assertThat(subscriptionUpdateTrialResponse.billingCycleDay()).isEqualTo(31L) + 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") + .additionalEmails(listOf("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") + .metadata(Customer.Metadata.builder().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() + .accountingProviders( + listOf( + 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.ofAmountDiscountInterval( + SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval + .builder() + .amountDiscount("amount_discount") + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(42.23) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(subscriptionUpdateTrialResponse.invoicingThreshold()) + .contains("invoicing_threshold") + assertThat(subscriptionUpdateTrialResponse.maximumIntervals()) + .containsExactly( + SubscriptionUpdateTrialResponse.MaximumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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().build()) + assertThat(subscriptionUpdateTrialResponse.minimumIntervals()) + .containsExactly( + SubscriptionUpdateTrialResponse.MinimumInterval.builder() + .appliesToPriceIds(listOf("string")) + .appliesToPriceIntervalIds(listOf("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(123L) + assertThat(subscriptionUpdateTrialResponse.plan()) + .isEqualTo( + Plan.builder() + .id("id") + .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( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + Plan.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Plan.Metadata.builder().build()) + .minimum( + Plan.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(123L) + .planPhases( + listOf( + Plan.PlanPhase.builder() + .id("id") + .description("description") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .duration(123L) + .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .maximum( + Plan.PlanPhase.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + Plan.PlanPhase.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(123L) + .build() + ) + ) + .prices( + listOf( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration + .DurationUnit + .DAY + ) + .build() + ) + .item( + Price.UnitPrice.Item.builder().id("id").name("name").build() + ) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .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(123L) + .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(123L) + .build() + ) + assertThat(subscriptionUpdateTrialResponse.priceIntervals()) + .containsExactly( + SubscriptionUpdateTrialResponse.PriceInterval.builder() + .id("id") + .billingCycleDay(123L) + .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")) + .fixedFeeQuantityTransitions( + listOf( + SubscriptionUpdateTrialResponse.PriceInterval.FixedFeeQuantityTransition + .builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(123L) + .build() + ) + ) + .price( + Price.ofUnitPrice( + Price.UnitPrice.builder() + .id("id") + .billableMetric( + Price.UnitPrice.BillableMetric.builder().id("id").build() + ) + .billingCycleConfiguration( + Price.UnitPrice.BillingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.BillingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .conversionRate(42.23) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Price.UnitPrice.CreditAllocation.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + Discount.ofPercentageDiscount( + PercentageDiscount.builder() + .appliesToPriceIds(listOf("string")) + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(1.0) + .reason("reason") + .build() + ) + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(42.23) + .invoicingCycleConfiguration( + Price.UnitPrice.InvoicingCycleConfiguration.builder() + .duration(123L) + .durationUnit( + Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit + .DAY + ) + .build() + ) + .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .maximum( + Price.UnitPrice.Maximum.builder() + .appliesToPriceIds(listOf("string")) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata(Price.UnitPrice.Metadata.builder().build()) + .minimum( + Price.UnitPrice.Minimum.builder() + .appliesToPriceIds(listOf("string")) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(Price.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(123L) + .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + Price.UnitPrice.UnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .build() + ) + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .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/services/blocking/SubscriptionServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index 37eb665f5..93500fa1d 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 @@ -25,7 +25,7 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionCreateResponse = subscriptionService.create( SubscriptionCreateParams.builder() .addAdjustments( @@ -333,8 +333,8 @@ class SubscriptionServiceTest { .trialDurationDays(123L) .build() ) - println(subscription) - subscription.validate() + println(subscriptionCreateResponse) + subscriptionCreateResponse.validate() } @Test @@ -381,7 +381,7 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionCancelResponse = subscriptionService.cancel( SubscriptionCancelParams.builder() .subscriptionId("subscription_id") @@ -389,8 +389,8 @@ class SubscriptionServiceTest { .cancellationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - println(subscription) - subscription.validate() + println(subscriptionCancelResponse) + subscriptionCancelResponse.validate() } @Test @@ -484,7 +484,7 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionPriceIntervalsResponse = subscriptionService.priceIntervals( SubscriptionPriceIntervalsParams.builder() .subscriptionId("subscription_id") @@ -716,8 +716,8 @@ class SubscriptionServiceTest { ) .build() ) - println(subscription) - subscription.validate() + println(subscriptionPriceIntervalsResponse) + subscriptionPriceIntervalsResponse.validate() } @Test @@ -728,7 +728,7 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionSchedulePlanChangeResponse = subscriptionService.schedulePlanChange( SubscriptionSchedulePlanChangeParams.builder() .subscriptionId("subscription_id") @@ -1060,8 +1060,8 @@ class SubscriptionServiceTest { .trialDurationDays(123L) .build() ) - println(subscription) - subscription.validate() + println(subscriptionSchedulePlanChangeResponse) + subscriptionSchedulePlanChangeResponse.validate() } @Test @@ -1072,15 +1072,15 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionTriggerPhaseResponse = subscriptionService.triggerPhase( SubscriptionTriggerPhaseParams.builder() .subscriptionId("subscription_id") .effectiveDate(LocalDate.parse("2019-12-27")) .build() ) - println(subscription) - subscription.validate() + println(subscriptionTriggerPhaseResponse) + subscriptionTriggerPhaseResponse.validate() } @Test @@ -1091,14 +1091,14 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionUnscheduleCancellationResponse = subscriptionService.unscheduleCancellation( SubscriptionUnscheduleCancellationParams.builder() .subscriptionId("subscription_id") .build() ) - println(subscription) - subscription.validate() + println(subscriptionUnscheduleCancellationResponse) + subscriptionUnscheduleCancellationResponse.validate() } @Test @@ -1109,15 +1109,15 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionUnscheduleFixedFeeQuantityUpdatesResponse = subscriptionService.unscheduleFixedFeeQuantityUpdates( SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.builder() .subscriptionId("subscription_id") .priceId("price_id") .build() ) - println(subscription) - subscription.validate() + println(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse) + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.validate() } @Test @@ -1128,14 +1128,14 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionUnschedulePendingPlanChangesResponse = subscriptionService.unschedulePendingPlanChanges( SubscriptionUnschedulePendingPlanChangesParams.builder() .subscriptionId("subscription_id") .build() ) - println(subscription) - subscription.validate() + println(subscriptionUnschedulePendingPlanChangesResponse) + subscriptionUnschedulePendingPlanChangesResponse.validate() } @Test @@ -1146,7 +1146,7 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionUpdateFixedFeeQuantityResponse = subscriptionService.updateFixedFeeQuantity( SubscriptionUpdateFixedFeeQuantityParams.builder() .subscriptionId("subscription_id") @@ -1156,8 +1156,8 @@ class SubscriptionServiceTest { .effectiveDate(LocalDate.parse("2022-12-21")) .build() ) - println(subscription) - subscription.validate() + println(subscriptionUpdateFixedFeeQuantityResponse) + subscriptionUpdateFixedFeeQuantityResponse.validate() } @Test @@ -1168,7 +1168,7 @@ class SubscriptionServiceTest { .apiKey("My API Key") .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionUpdateTrialResponse = subscriptionService.updateTrial( SubscriptionUpdateTrialParams.builder() .subscriptionId("subscription_id") @@ -1180,7 +1180,7 @@ class SubscriptionServiceTest { .shift(true) .build() ) - println(subscription) - subscription.validate() + println(subscriptionUpdateTrialResponse) + subscriptionUpdateTrialResponse.validate() } } From 17f2f02a2e2867762d8ccc07c093516ff4a4c72b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 21:01:58 +0000 Subject: [PATCH 6/6] release: 0.2.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 13 +++++++++++++ README.md | 6 +++--- build.gradle.kts | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d2ac0bdd..10f309169 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.2.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e304d121a..caf28e80d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.2.0 (2024-11-01) + +Full Changelog: [v0.1.0...v0.2.0](https://github.com/orbcorp/orb-java/compare/v0.1.0...v0.2.0) + +### Features + +* **api:** api update ([#90](https://github.com/orbcorp/orb-java/issues/90)) ([9058993](https://github.com/orbcorp/orb-java/commit/9058993fe3a504740a1726494688780f3a3ef31b)) + + +### Chores + +* **internal:** version bump ([#89](https://github.com/orbcorp/orb-java/issues/89)) ([eae6b90](https://github.com/orbcorp/orb-java/commit/eae6b90e8a24ae823ddf08ab9cf39cc2c5d3b8e3)) + ## 0.1.0 (2024-10-28) Full Changelog: [v0.1.0-alpha.7...v0.1.0](https://github.com/orbcorp/orb-java/compare/v0.1.0-alpha.7...v0.1.0) diff --git a/README.md b/README.md index 458e70f97..0a86c1546 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.1.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.2.0) @@ -25,7 +25,7 @@ The REST API documentation can be foundĀ on [docs.withorb.com](https://docs.with ```kotlin -implementation("com.withorb.api:orb-java:0.1.0") +implementation("com.withorb.api:orb-java:0.2.0") ``` #### Maven @@ -34,7 +34,7 @@ implementation("com.withorb.api:orb-java:0.1.0") com.withorb.api orb-java - 0.1.0 + 0.2.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 29e29d0d9..a22c02635 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { allprojects { group = "com.withorb.api" - version = "0.1.0" // x-release-please-version + version = "0.2.0" // x-release-please-version }