diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 5ea5d0cf..9afeabed 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.1.0-beta.30"
+ ".": "0.1.0-beta.31"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 2fab76ed..515f4458 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 111
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stigg/stigg-db0e894e98bd8b3dcb73ff6aaa78775fa84c059a4b1ea8f6ca481ae826affaaa.yml
-openapi_spec_hash: 7a1b7f96561158341899feff23422ac6
-config_hash: 2e65c1178cfd5d688faf5c9b1a48a732
+configured_endpoints: 113
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stigg/stigg-5ac3181e71c63e5c6546c3b332853485306095584f73dc3e5942988edec5ab4b.yml
+openapi_spec_hash: cb4c8b53e6983a1d06b7b89c742ed74a
+config_hash: 7c6fb6cddb559f056a68eaef8c1b9921
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd22fbba..d31c329e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 0.1.0-beta.31 (2026-07-01)
+
+Full Changelog: [v0.1.0-beta.30...v0.1.0-beta.31](https://github.com/stiggio/stigg-java/compare/v0.1.0-beta.30...v0.1.0-beta.31)
+
+### Features
+
+* **api:** add consume/consumeAsync methods to credits consumption ([32b02b4](https://github.com/stiggio/stigg-java/commit/32b02b4663bf1b98966b08288afc958b03a7d12d))
+
## 0.1.0-beta.30 (2026-06-30)
Full Changelog: [v0.1.0-beta.29...v0.1.0-beta.30](https://github.com/stiggio/stigg-java/compare/v0.1.0-beta.29...v0.1.0-beta.30)
diff --git a/README.md b/README.md
index 272f30f2..27149c7e 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/io.stigg/stigg-java/0.1.0-beta.30)
-[](https://javadoc.io/doc/io.stigg/stigg-java/0.1.0-beta.30)
+[](https://central.sonatype.com/artifact/io.stigg/stigg-java/0.1.0-beta.31)
+[](https://javadoc.io/doc/io.stigg/stigg-java/0.1.0-beta.31)
@@ -22,7 +22,7 @@ Use the Stigg MCP Server to enable AI assistants to interact with this API, allo
-Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.stigg/stigg-java/0.1.0-beta.30).
+Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.stigg/stigg-java/0.1.0-beta.31).
@@ -33,7 +33,7 @@ Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.stigg/stigg-jav
### Gradle
```kotlin
-implementation("io.stigg:stigg-java:0.1.0-beta.30")
+implementation("io.stigg:stigg-java:0.1.0-beta.31")
```
### Maven
@@ -42,7 +42,7 @@ implementation("io.stigg:stigg-java:0.1.0-beta.30")
io.stigg
stigg-java
- 0.1.0-beta.30
+ 0.1.0-beta.31
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 7a9f96a0..6fd168d3 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "io.stigg"
- version = "0.1.0-beta.30" // x-release-please-version
+ version = "0.1.0-beta.31" // x-release-please-version
}
subprojects {
diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeAsyncParams.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeAsyncParams.kt
new file mode 100644
index 00000000..73b4c9b0
--- /dev/null
+++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeAsyncParams.kt
@@ -0,0 +1,1056 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package io.stigg.models.v1.credits.consumption
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import io.stigg.core.ExcludeMissing
+import io.stigg.core.JsonField
+import io.stigg.core.JsonMissing
+import io.stigg.core.JsonValue
+import io.stigg.core.Params
+import io.stigg.core.checkKnown
+import io.stigg.core.checkRequired
+import io.stigg.core.http.Headers
+import io.stigg.core.http.QueryParams
+import io.stigg.core.toImmutable
+import io.stigg.errors.StiggInvalidDataException
+import java.time.OffsetDateTime
+import java.util.Collections
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * Consumes credits directly from customer wallets asynchronously. Consumptions are reconciled
+ * asynchronously into the credit balances.
+ */
+class ConsumptionConsumeAsyncParams
+private constructor(
+ private val xAccountId: String?,
+ private val xEnvironmentId: String?,
+ private val body: Body,
+ private val additionalHeaders: Headers,
+ private val additionalQueryParams: QueryParams,
+) : Params {
+
+ fun xAccountId(): Optional = Optional.ofNullable(xAccountId)
+
+ fun xEnvironmentId(): Optional = Optional.ofNullable(xEnvironmentId)
+
+ /**
+ * The credit consumptions to report (up to 1000)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is unexpectedly
+ * missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun consumptions(): List = body.consumptions()
+
+ /**
+ * Returns the raw JSON value of [consumptions].
+ *
+ * Unlike [consumptions], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _consumptions(): JsonField> = body._consumptions()
+
+ fun _additionalBodyProperties(): Map = body._additionalProperties()
+
+ /** Additional headers to send with the request. */
+ fun _additionalHeaders(): Headers = additionalHeaders
+
+ /** Additional query param to send with the request. */
+ fun _additionalQueryParams(): QueryParams = additionalQueryParams
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of
+ * [ConsumptionConsumeAsyncParams].
+ *
+ * The following fields are required:
+ * ```java
+ * .consumptions()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [ConsumptionConsumeAsyncParams]. */
+ class Builder internal constructor() {
+
+ private var xAccountId: String? = null
+ private var xEnvironmentId: String? = null
+ private var body: Body.Builder = Body.builder()
+ private var additionalHeaders: Headers.Builder = Headers.builder()
+ private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
+
+ @JvmSynthetic
+ internal fun from(consumptionConsumeAsyncParams: ConsumptionConsumeAsyncParams) = apply {
+ xAccountId = consumptionConsumeAsyncParams.xAccountId
+ xEnvironmentId = consumptionConsumeAsyncParams.xEnvironmentId
+ body = consumptionConsumeAsyncParams.body.toBuilder()
+ additionalHeaders = consumptionConsumeAsyncParams.additionalHeaders.toBuilder()
+ additionalQueryParams = consumptionConsumeAsyncParams.additionalQueryParams.toBuilder()
+ }
+
+ fun xAccountId(xAccountId: String?) = apply { this.xAccountId = xAccountId }
+
+ /** Alias for calling [Builder.xAccountId] with `xAccountId.orElse(null)`. */
+ fun xAccountId(xAccountId: Optional) = xAccountId(xAccountId.getOrNull())
+
+ fun xEnvironmentId(xEnvironmentId: String?) = apply { this.xEnvironmentId = xEnvironmentId }
+
+ /** Alias for calling [Builder.xEnvironmentId] with `xEnvironmentId.orElse(null)`. */
+ fun xEnvironmentId(xEnvironmentId: Optional) =
+ xEnvironmentId(xEnvironmentId.getOrNull())
+
+ /**
+ * Sets the entire request body.
+ *
+ * This is generally only useful if you are already constructing the body separately.
+ * Otherwise, it's more convenient to use the top-level setters instead:
+ * - [consumptions]
+ */
+ fun body(body: Body) = apply { this.body = body.toBuilder() }
+
+ /** The credit consumptions to report (up to 1000) */
+ fun consumptions(consumptions: List) = apply {
+ body.consumptions(consumptions)
+ }
+
+ /**
+ * Sets [Builder.consumptions] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.consumptions] with a well-typed `List`
+ * value instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun consumptions(consumptions: JsonField>) = apply {
+ body.consumptions(consumptions)
+ }
+
+ /**
+ * Adds a single [Consumption] to [consumptions].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addConsumption(consumption: Consumption) = apply { body.addConsumption(consumption) }
+
+ fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
+ body.additionalProperties(additionalBodyProperties)
+ }
+
+ fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
+ body.putAdditionalProperty(key, value)
+ }
+
+ fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
+ apply {
+ body.putAllAdditionalProperties(additionalBodyProperties)
+ }
+
+ fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) }
+
+ fun removeAllAdditionalBodyProperties(keys: Set) = apply {
+ body.removeAllAdditionalProperties(keys)
+ }
+
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
+ fun additionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
+ fun putAdditionalHeader(name: String, value: String) = apply {
+ additionalHeaders.put(name, value)
+ }
+
+ fun putAdditionalHeaders(name: String, values: Iterable) = apply {
+ additionalHeaders.put(name, values)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
+ }
+
+ fun replaceAdditionalHeaders(name: String, value: String) = apply {
+ additionalHeaders.replace(name, value)
+ }
+
+ fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
+ additionalHeaders.replace(name, values)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
+ }
+
+ fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
+
+ fun removeAllAdditionalHeaders(names: Set) = apply {
+ additionalHeaders.removeAll(names)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: Map>) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
+ }
+
+ fun putAdditionalQueryParam(key: String, value: String) = apply {
+ additionalQueryParams.put(key, value)
+ }
+
+ fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
+ additionalQueryParams.put(key, values)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
+ apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
+ }
+
+ fun replaceAdditionalQueryParams(key: String, value: String) = apply {
+ additionalQueryParams.replace(key, value)
+ }
+
+ fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
+ additionalQueryParams.replace(key, values)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
+ apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
+ }
+
+ fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
+
+ fun removeAllAdditionalQueryParams(keys: Set) = apply {
+ additionalQueryParams.removeAll(keys)
+ }
+
+ /**
+ * Returns an immutable instance of [ConsumptionConsumeAsyncParams].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .consumptions()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): ConsumptionConsumeAsyncParams =
+ ConsumptionConsumeAsyncParams(
+ xAccountId,
+ xEnvironmentId,
+ body.build(),
+ additionalHeaders.build(),
+ additionalQueryParams.build(),
+ )
+ }
+
+ fun _body(): Body = body
+
+ override fun _headers(): Headers =
+ Headers.builder()
+ .apply {
+ xAccountId?.let { put("X-ACCOUNT-ID", it) }
+ xEnvironmentId?.let { put("X-ENVIRONMENT-ID", it) }
+ putAll(additionalHeaders)
+ }
+ .build()
+
+ override fun _queryParams(): QueryParams = additionalQueryParams
+
+ /** Request body for consuming credits directly from wallets asynchronously */
+ class Body
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val consumptions: JsonField>,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("consumptions")
+ @ExcludeMissing
+ consumptions: JsonField> = JsonMissing.of()
+ ) : this(consumptions, mutableMapOf())
+
+ /**
+ * The credit consumptions to report (up to 1000)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun consumptions(): List = consumptions.getRequired("consumptions")
+
+ /**
+ * Returns the raw JSON value of [consumptions].
+ *
+ * Unlike [consumptions], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("consumptions")
+ @ExcludeMissing
+ fun _consumptions(): JsonField> = consumptions
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Body].
+ *
+ * The following fields are required:
+ * ```java
+ * .consumptions()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Body]. */
+ class Builder internal constructor() {
+
+ private var consumptions: JsonField>? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(body: Body) = apply {
+ consumptions = body.consumptions.map { it.toMutableList() }
+ additionalProperties = body.additionalProperties.toMutableMap()
+ }
+
+ /** The credit consumptions to report (up to 1000) */
+ fun consumptions(consumptions: List) =
+ consumptions(JsonField.of(consumptions))
+
+ /**
+ * Sets [Builder.consumptions] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.consumptions] with a well-typed `List`
+ * value instead. This method is primarily for setting the field to an undocumented or
+ * not yet supported value.
+ */
+ fun consumptions(consumptions: JsonField>) = apply {
+ this.consumptions = consumptions.map { it.toMutableList() }
+ }
+
+ /**
+ * Adds a single [Consumption] to [consumptions].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addConsumption(consumption: Consumption) = apply {
+ consumptions =
+ (consumptions ?: JsonField.of(mutableListOf())).also {
+ checkKnown("consumptions", it).add(consumption)
+ }
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Body].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .consumptions()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Body =
+ Body(
+ checkRequired("consumptions", consumptions).map { it.toImmutable() },
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StiggInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Body = apply {
+ if (validated) {
+ return@apply
+ }
+
+ consumptions().forEach { it.validate() }
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StiggInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (consumptions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Body &&
+ consumptions == other.consumptions &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(consumptions, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Body{consumptions=$consumptions, additionalProperties=$additionalProperties}"
+ }
+
+ /** Request body for consuming credits directly from a wallet */
+ class Consumption
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val amount: JsonField,
+ private val currencyId: JsonField,
+ private val customerId: JsonField,
+ private val idempotencyKey: JsonField,
+ private val createdAt: JsonField,
+ private val dimensions: JsonField,
+ private val resourceId: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(),
+ @JsonProperty("currencyId")
+ @ExcludeMissing
+ currencyId: JsonField = JsonMissing.of(),
+ @JsonProperty("customerId")
+ @ExcludeMissing
+ customerId: JsonField = JsonMissing.of(),
+ @JsonProperty("idempotencyKey")
+ @ExcludeMissing
+ idempotencyKey: JsonField = JsonMissing.of(),
+ @JsonProperty("createdAt")
+ @ExcludeMissing
+ createdAt: JsonField = JsonMissing.of(),
+ @JsonProperty("dimensions")
+ @ExcludeMissing
+ dimensions: JsonField = JsonMissing.of(),
+ @JsonProperty("resourceId")
+ @ExcludeMissing
+ resourceId: JsonField = JsonMissing.of(),
+ ) : this(
+ amount,
+ currencyId,
+ customerId,
+ idempotencyKey,
+ createdAt,
+ dimensions,
+ resourceId,
+ mutableMapOf(),
+ )
+
+ /**
+ * The amount of credits to consume
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun amount(): Double = amount.getRequired("amount")
+
+ /**
+ * The credit currency to consume from (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun currencyId(): String = currencyId.getRequired("currencyId")
+
+ /**
+ * The customer to consume credits from (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun customerId(): String = customerId.getRequired("customerId")
+
+ /**
+ * A unique key used to deduplicate the consumption (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun idempotencyKey(): String = idempotencyKey.getRequired("idempotencyKey")
+
+ /**
+ * Optional timestamp the consumption is attributed to
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun createdAt(): Optional = createdAt.getOptional("createdAt")
+
+ /**
+ * Optional dimensions describing the consumption
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun dimensions(): Optional = dimensions.getOptional("dimensions")
+
+ /**
+ * Optional resource the consumption is attributed to
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun resourceId(): Optional = resourceId.getOptional("resourceId")
+
+ /**
+ * Returns the raw JSON value of [amount].
+ *
+ * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount
+
+ /**
+ * Returns the raw JSON value of [currencyId].
+ *
+ * Unlike [currencyId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("currencyId")
+ @ExcludeMissing
+ fun _currencyId(): JsonField = currencyId
+
+ /**
+ * Returns the raw JSON value of [customerId].
+ *
+ * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("customerId")
+ @ExcludeMissing
+ fun _customerId(): JsonField = customerId
+
+ /**
+ * Returns the raw JSON value of [idempotencyKey].
+ *
+ * Unlike [idempotencyKey], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("idempotencyKey")
+ @ExcludeMissing
+ fun _idempotencyKey(): JsonField = idempotencyKey
+
+ /**
+ * Returns the raw JSON value of [createdAt].
+ *
+ * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("createdAt")
+ @ExcludeMissing
+ fun _createdAt(): JsonField = createdAt
+
+ /**
+ * Returns the raw JSON value of [dimensions].
+ *
+ * Unlike [dimensions], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("dimensions")
+ @ExcludeMissing
+ fun _dimensions(): JsonField = dimensions
+
+ /**
+ * Returns the raw JSON value of [resourceId].
+ *
+ * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("resourceId")
+ @ExcludeMissing
+ fun _resourceId(): JsonField = resourceId
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Consumption].
+ *
+ * The following fields are required:
+ * ```java
+ * .amount()
+ * .currencyId()
+ * .customerId()
+ * .idempotencyKey()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Consumption]. */
+ class Builder internal constructor() {
+
+ private var amount: JsonField? = null
+ private var currencyId: JsonField? = null
+ private var customerId: JsonField? = null
+ private var idempotencyKey: JsonField? = null
+ private var createdAt: JsonField = JsonMissing.of()
+ private var dimensions: JsonField = JsonMissing.of()
+ private var resourceId: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(consumption: Consumption) = apply {
+ amount = consumption.amount
+ currencyId = consumption.currencyId
+ customerId = consumption.customerId
+ idempotencyKey = consumption.idempotencyKey
+ createdAt = consumption.createdAt
+ dimensions = consumption.dimensions
+ resourceId = consumption.resourceId
+ additionalProperties = consumption.additionalProperties.toMutableMap()
+ }
+
+ /** The amount of credits to consume */
+ fun amount(amount: Double) = amount(JsonField.of(amount))
+
+ /**
+ * Sets [Builder.amount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.amount] with a well-typed [Double] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun amount(amount: JsonField) = apply { this.amount = amount }
+
+ /** The credit currency to consume from (required) */
+ fun currencyId(currencyId: String) = currencyId(JsonField.of(currencyId))
+
+ /**
+ * Sets [Builder.currencyId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.currencyId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun currencyId(currencyId: JsonField) = apply { this.currencyId = currencyId }
+
+ /** The customer to consume credits from (required) */
+ fun customerId(customerId: String) = customerId(JsonField.of(customerId))
+
+ /**
+ * Sets [Builder.customerId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.customerId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun customerId(customerId: JsonField) = apply { this.customerId = customerId }
+
+ /** A unique key used to deduplicate the consumption (required) */
+ fun idempotencyKey(idempotencyKey: String) =
+ idempotencyKey(JsonField.of(idempotencyKey))
+
+ /**
+ * Sets [Builder.idempotencyKey] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.idempotencyKey] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun idempotencyKey(idempotencyKey: JsonField) = apply {
+ this.idempotencyKey = idempotencyKey
+ }
+
+ /** Optional timestamp the consumption is attributed to */
+ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))
+
+ /**
+ * Sets [Builder.createdAt] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun createdAt(createdAt: JsonField) = apply {
+ this.createdAt = createdAt
+ }
+
+ /** Optional dimensions describing the consumption */
+ fun dimensions(dimensions: Dimensions) = dimensions(JsonField.of(dimensions))
+
+ /**
+ * Sets [Builder.dimensions] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.dimensions] with a well-typed [Dimensions] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun dimensions(dimensions: JsonField) = apply {
+ this.dimensions = dimensions
+ }
+
+ /** Optional resource the consumption is attributed to */
+ fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId))
+
+ /**
+ * Sets [Builder.resourceId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.resourceId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun resourceId(resourceId: JsonField) = apply { this.resourceId = resourceId }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Consumption].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .amount()
+ * .currencyId()
+ * .customerId()
+ * .idempotencyKey()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Consumption =
+ Consumption(
+ checkRequired("amount", amount),
+ checkRequired("currencyId", currencyId),
+ checkRequired("customerId", customerId),
+ checkRequired("idempotencyKey", idempotencyKey),
+ createdAt,
+ dimensions,
+ resourceId,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StiggInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Consumption = apply {
+ if (validated) {
+ return@apply
+ }
+
+ amount()
+ currencyId()
+ customerId()
+ idempotencyKey()
+ createdAt()
+ dimensions().ifPresent { it.validate() }
+ resourceId()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StiggInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (amount.asKnown().isPresent) 1 else 0) +
+ (if (currencyId.asKnown().isPresent) 1 else 0) +
+ (if (customerId.asKnown().isPresent) 1 else 0) +
+ (if (idempotencyKey.asKnown().isPresent) 1 else 0) +
+ (if (createdAt.asKnown().isPresent) 1 else 0) +
+ (dimensions.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (resourceId.asKnown().isPresent) 1 else 0)
+
+ /** Optional dimensions describing the consumption */
+ class Dimensions
+ @JsonCreator
+ private constructor(
+ @com.fasterxml.jackson.annotation.JsonValue
+ private val additionalProperties: Map
+ ) {
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map = additionalProperties
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /** Returns a mutable builder for constructing an instance of [Dimensions]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Dimensions]. */
+ class Builder internal constructor() {
+
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(dimensions: Dimensions) = apply {
+ additionalProperties = dimensions.additionalProperties.toMutableMap()
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Dimensions].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Dimensions = Dimensions(additionalProperties.toImmutable())
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing
+ * fields.
+ *
+ * @throws StiggInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Dimensions = apply {
+ if (validated) {
+ return@apply
+ }
+
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StiggInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Dimensions && additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() = "Dimensions{additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Consumption &&
+ amount == other.amount &&
+ currencyId == other.currencyId &&
+ customerId == other.customerId &&
+ idempotencyKey == other.idempotencyKey &&
+ createdAt == other.createdAt &&
+ dimensions == other.dimensions &&
+ resourceId == other.resourceId &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ amount,
+ currencyId,
+ customerId,
+ idempotencyKey,
+ createdAt,
+ dimensions,
+ resourceId,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Consumption{amount=$amount, currencyId=$currencyId, customerId=$customerId, idempotencyKey=$idempotencyKey, createdAt=$createdAt, dimensions=$dimensions, resourceId=$resourceId, additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is ConsumptionConsumeAsyncParams &&
+ xAccountId == other.xAccountId &&
+ xEnvironmentId == other.xEnvironmentId &&
+ body == other.body &&
+ additionalHeaders == other.additionalHeaders &&
+ additionalQueryParams == other.additionalQueryParams
+ }
+
+ override fun hashCode(): Int =
+ Objects.hash(xAccountId, xEnvironmentId, body, additionalHeaders, additionalQueryParams)
+
+ override fun toString() =
+ "ConsumptionConsumeAsyncParams{xAccountId=$xAccountId, xEnvironmentId=$xEnvironmentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
+}
diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeAsyncResponse.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeAsyncResponse.kt
new file mode 100644
index 00000000..37d64021
--- /dev/null
+++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeAsyncResponse.kt
@@ -0,0 +1,170 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package io.stigg.models.v1.credits.consumption
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import io.stigg.core.ExcludeMissing
+import io.stigg.core.JsonMissing
+import io.stigg.core.JsonValue
+import io.stigg.core.checkRequired
+import io.stigg.errors.StiggInvalidDataException
+import java.util.Collections
+import java.util.Objects
+
+/** Response object */
+class ConsumptionConsumeAsyncResponse
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val data: JsonValue,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of()
+ ) : this(data, mutableMapOf())
+
+ /**
+ * Confirmation that the credit consumptions were accepted for processing
+ *
+ * This arbitrary value can be deserialized into a custom type using the `convert` method:
+ * ```java
+ * MyClass myObject = consumptionConsumeAsyncResponse.data().convert(MyClass.class);
+ * ```
+ */
+ @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of
+ * [ConsumptionConsumeAsyncResponse].
+ *
+ * The following fields are required:
+ * ```java
+ * .data()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [ConsumptionConsumeAsyncResponse]. */
+ class Builder internal constructor() {
+
+ private var data: JsonValue? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(consumptionConsumeAsyncResponse: ConsumptionConsumeAsyncResponse) =
+ apply {
+ data = consumptionConsumeAsyncResponse.data
+ additionalProperties =
+ consumptionConsumeAsyncResponse.additionalProperties.toMutableMap()
+ }
+
+ /** Confirmation that the credit consumptions were accepted for processing */
+ fun data(data: JsonValue) = apply { this.data = data }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [ConsumptionConsumeAsyncResponse].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .data()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): ConsumptionConsumeAsyncResponse =
+ ConsumptionConsumeAsyncResponse(
+ checkRequired("data", data),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StiggInvalidDataException if any value type in this object doesn't match its expected
+ * type.
+ */
+ fun validate(): ConsumptionConsumeAsyncResponse = apply {
+ if (validated) {
+ return@apply
+ }
+
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StiggInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic internal fun validity(): Int = 0
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is ConsumptionConsumeAsyncResponse &&
+ data == other.data &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "ConsumptionConsumeAsyncResponse{data=$data, additionalProperties=$additionalProperties}"
+}
diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeParams.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeParams.kt
new file mode 100644
index 00000000..1b57d459
--- /dev/null
+++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeParams.kt
@@ -0,0 +1,1022 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package io.stigg.models.v1.credits.consumption
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import io.stigg.core.ExcludeMissing
+import io.stigg.core.JsonField
+import io.stigg.core.JsonMissing
+import io.stigg.core.JsonValue
+import io.stigg.core.Params
+import io.stigg.core.checkRequired
+import io.stigg.core.http.Headers
+import io.stigg.core.http.QueryParams
+import io.stigg.core.toImmutable
+import io.stigg.errors.StiggInvalidDataException
+import java.time.OffsetDateTime
+import java.util.Collections
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+/**
+ * Consumes a specified amount of credits directly from a customer wallet, with no feature mapping.
+ * Returns the optimistic balance.
+ */
+class ConsumptionConsumeParams
+private constructor(
+ private val xAccountId: String?,
+ private val xEnvironmentId: String?,
+ private val body: Body,
+ private val additionalHeaders: Headers,
+ private val additionalQueryParams: QueryParams,
+) : Params {
+
+ fun xAccountId(): Optional = Optional.ofNullable(xAccountId)
+
+ fun xEnvironmentId(): Optional = Optional.ofNullable(xEnvironmentId)
+
+ /**
+ * The amount of credits to consume
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is unexpectedly
+ * missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun amount(): Double = body.amount()
+
+ /**
+ * The credit currency to consume from (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is unexpectedly
+ * missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun currencyId(): String = body.currencyId()
+
+ /**
+ * The customer to consume credits from (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is unexpectedly
+ * missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun customerId(): String = body.customerId()
+
+ /**
+ * A unique key used to deduplicate the consumption (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is unexpectedly
+ * missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun idempotencyKey(): String = body.idempotencyKey()
+
+ /**
+ * Optional timestamp the consumption is attributed to
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun createdAt(): Optional = body.createdAt()
+
+ /**
+ * Optional dimensions describing the consumption
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun dimensions(): Optional = body.dimensions()
+
+ /**
+ * Optional resource the consumption is attributed to
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun resourceId(): Optional = body.resourceId()
+
+ /**
+ * Returns the raw JSON value of [amount].
+ *
+ * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _amount(): JsonField = body._amount()
+
+ /**
+ * Returns the raw JSON value of [currencyId].
+ *
+ * Unlike [currencyId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _currencyId(): JsonField = body._currencyId()
+
+ /**
+ * Returns the raw JSON value of [customerId].
+ *
+ * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _customerId(): JsonField = body._customerId()
+
+ /**
+ * Returns the raw JSON value of [idempotencyKey].
+ *
+ * Unlike [idempotencyKey], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _idempotencyKey(): JsonField = body._idempotencyKey()
+
+ /**
+ * Returns the raw JSON value of [createdAt].
+ *
+ * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _createdAt(): JsonField = body._createdAt()
+
+ /**
+ * Returns the raw JSON value of [dimensions].
+ *
+ * Unlike [dimensions], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _dimensions(): JsonField = body._dimensions()
+
+ /**
+ * Returns the raw JSON value of [resourceId].
+ *
+ * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ fun _resourceId(): JsonField = body._resourceId()
+
+ fun _additionalBodyProperties(): Map = body._additionalProperties()
+
+ /** Additional headers to send with the request. */
+ fun _additionalHeaders(): Headers = additionalHeaders
+
+ /** Additional query param to send with the request. */
+ fun _additionalQueryParams(): QueryParams = additionalQueryParams
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [ConsumptionConsumeParams].
+ *
+ * The following fields are required:
+ * ```java
+ * .amount()
+ * .currencyId()
+ * .customerId()
+ * .idempotencyKey()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [ConsumptionConsumeParams]. */
+ class Builder internal constructor() {
+
+ private var xAccountId: String? = null
+ private var xEnvironmentId: String? = null
+ private var body: Body.Builder = Body.builder()
+ private var additionalHeaders: Headers.Builder = Headers.builder()
+ private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
+
+ @JvmSynthetic
+ internal fun from(consumptionConsumeParams: ConsumptionConsumeParams) = apply {
+ xAccountId = consumptionConsumeParams.xAccountId
+ xEnvironmentId = consumptionConsumeParams.xEnvironmentId
+ body = consumptionConsumeParams.body.toBuilder()
+ additionalHeaders = consumptionConsumeParams.additionalHeaders.toBuilder()
+ additionalQueryParams = consumptionConsumeParams.additionalQueryParams.toBuilder()
+ }
+
+ fun xAccountId(xAccountId: String?) = apply { this.xAccountId = xAccountId }
+
+ /** Alias for calling [Builder.xAccountId] with `xAccountId.orElse(null)`. */
+ fun xAccountId(xAccountId: Optional) = xAccountId(xAccountId.getOrNull())
+
+ fun xEnvironmentId(xEnvironmentId: String?) = apply { this.xEnvironmentId = xEnvironmentId }
+
+ /** Alias for calling [Builder.xEnvironmentId] with `xEnvironmentId.orElse(null)`. */
+ fun xEnvironmentId(xEnvironmentId: Optional) =
+ xEnvironmentId(xEnvironmentId.getOrNull())
+
+ /**
+ * Sets the entire request body.
+ *
+ * This is generally only useful if you are already constructing the body separately.
+ * Otherwise, it's more convenient to use the top-level setters instead:
+ * - [amount]
+ * - [currencyId]
+ * - [customerId]
+ * - [idempotencyKey]
+ * - [createdAt]
+ * - etc.
+ */
+ fun body(body: Body) = apply { this.body = body.toBuilder() }
+
+ /** The amount of credits to consume */
+ fun amount(amount: Double) = apply { body.amount(amount) }
+
+ /**
+ * Sets [Builder.amount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.amount] with a well-typed [Double] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun amount(amount: JsonField) = apply { body.amount(amount) }
+
+ /** The credit currency to consume from (required) */
+ fun currencyId(currencyId: String) = apply { body.currencyId(currencyId) }
+
+ /**
+ * Sets [Builder.currencyId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.currencyId] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun currencyId(currencyId: JsonField) = apply { body.currencyId(currencyId) }
+
+ /** The customer to consume credits from (required) */
+ fun customerId(customerId: String) = apply { body.customerId(customerId) }
+
+ /**
+ * Sets [Builder.customerId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.customerId] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun customerId(customerId: JsonField) = apply { body.customerId(customerId) }
+
+ /** A unique key used to deduplicate the consumption (required) */
+ fun idempotencyKey(idempotencyKey: String) = apply { body.idempotencyKey(idempotencyKey) }
+
+ /**
+ * Sets [Builder.idempotencyKey] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.idempotencyKey] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun idempotencyKey(idempotencyKey: JsonField) = apply {
+ body.idempotencyKey(idempotencyKey)
+ }
+
+ /** Optional timestamp the consumption is attributed to */
+ fun createdAt(createdAt: OffsetDateTime) = apply { body.createdAt(createdAt) }
+
+ /**
+ * Sets [Builder.createdAt] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun createdAt(createdAt: JsonField) = apply { body.createdAt(createdAt) }
+
+ /** Optional dimensions describing the consumption */
+ fun dimensions(dimensions: Dimensions) = apply { body.dimensions(dimensions) }
+
+ /**
+ * Sets [Builder.dimensions] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.dimensions] with a well-typed [Dimensions] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun dimensions(dimensions: JsonField) = apply { body.dimensions(dimensions) }
+
+ /** Optional resource the consumption is attributed to */
+ fun resourceId(resourceId: String) = apply { body.resourceId(resourceId) }
+
+ /**
+ * Sets [Builder.resourceId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.resourceId] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun resourceId(resourceId: JsonField) = apply { body.resourceId(resourceId) }
+
+ fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
+ body.additionalProperties(additionalBodyProperties)
+ }
+
+ fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
+ body.putAdditionalProperty(key, value)
+ }
+
+ fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
+ apply {
+ body.putAllAdditionalProperties(additionalBodyProperties)
+ }
+
+ fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) }
+
+ fun removeAllAdditionalBodyProperties(keys: Set) = apply {
+ body.removeAllAdditionalProperties(keys)
+ }
+
+ fun additionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
+ fun additionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.clear()
+ putAllAdditionalHeaders(additionalHeaders)
+ }
+
+ fun putAdditionalHeader(name: String, value: String) = apply {
+ additionalHeaders.put(name, value)
+ }
+
+ fun putAdditionalHeaders(name: String, values: Iterable) = apply {
+ additionalHeaders.put(name, values)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
+ }
+
+ fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.putAll(additionalHeaders)
+ }
+
+ fun replaceAdditionalHeaders(name: String, value: String) = apply {
+ additionalHeaders.replace(name, value)
+ }
+
+ fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
+ additionalHeaders.replace(name, values)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
+ }
+
+ fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
+ this.additionalHeaders.replaceAll(additionalHeaders)
+ }
+
+ fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
+
+ fun removeAllAdditionalHeaders(names: Set) = apply {
+ additionalHeaders.removeAll(names)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
+ }
+
+ fun additionalQueryParams(additionalQueryParams: Map>) = apply {
+ this.additionalQueryParams.clear()
+ putAllAdditionalQueryParams(additionalQueryParams)
+ }
+
+ fun putAdditionalQueryParam(key: String, value: String) = apply {
+ additionalQueryParams.put(key, value)
+ }
+
+ fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
+ additionalQueryParams.put(key, values)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
+ }
+
+ fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
+ apply {
+ this.additionalQueryParams.putAll(additionalQueryParams)
+ }
+
+ fun replaceAdditionalQueryParams(key: String, value: String) = apply {
+ additionalQueryParams.replace(key, value)
+ }
+
+ fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
+ additionalQueryParams.replace(key, values)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
+ }
+
+ fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
+ apply {
+ this.additionalQueryParams.replaceAll(additionalQueryParams)
+ }
+
+ fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
+
+ fun removeAllAdditionalQueryParams(keys: Set) = apply {
+ additionalQueryParams.removeAll(keys)
+ }
+
+ /**
+ * Returns an immutable instance of [ConsumptionConsumeParams].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .amount()
+ * .currencyId()
+ * .customerId()
+ * .idempotencyKey()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): ConsumptionConsumeParams =
+ ConsumptionConsumeParams(
+ xAccountId,
+ xEnvironmentId,
+ body.build(),
+ additionalHeaders.build(),
+ additionalQueryParams.build(),
+ )
+ }
+
+ fun _body(): Body = body
+
+ override fun _headers(): Headers =
+ Headers.builder()
+ .apply {
+ xAccountId?.let { put("X-ACCOUNT-ID", it) }
+ xEnvironmentId?.let { put("X-ENVIRONMENT-ID", it) }
+ putAll(additionalHeaders)
+ }
+ .build()
+
+ override fun _queryParams(): QueryParams = additionalQueryParams
+
+ /** Request body for consuming credits directly from a wallet */
+ class Body
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val amount: JsonField,
+ private val currencyId: JsonField,
+ private val customerId: JsonField,
+ private val idempotencyKey: JsonField,
+ private val createdAt: JsonField,
+ private val dimensions: JsonField,
+ private val resourceId: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(),
+ @JsonProperty("currencyId")
+ @ExcludeMissing
+ currencyId: JsonField = JsonMissing.of(),
+ @JsonProperty("customerId")
+ @ExcludeMissing
+ customerId: JsonField = JsonMissing.of(),
+ @JsonProperty("idempotencyKey")
+ @ExcludeMissing
+ idempotencyKey: JsonField = JsonMissing.of(),
+ @JsonProperty("createdAt")
+ @ExcludeMissing
+ createdAt: JsonField = JsonMissing.of(),
+ @JsonProperty("dimensions")
+ @ExcludeMissing
+ dimensions: JsonField = JsonMissing.of(),
+ @JsonProperty("resourceId")
+ @ExcludeMissing
+ resourceId: JsonField = JsonMissing.of(),
+ ) : this(
+ amount,
+ currencyId,
+ customerId,
+ idempotencyKey,
+ createdAt,
+ dimensions,
+ resourceId,
+ mutableMapOf(),
+ )
+
+ /**
+ * The amount of credits to consume
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun amount(): Double = amount.getRequired("amount")
+
+ /**
+ * The credit currency to consume from (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun currencyId(): String = currencyId.getRequired("currencyId")
+
+ /**
+ * The customer to consume credits from (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun customerId(): String = customerId.getRequired("customerId")
+
+ /**
+ * A unique key used to deduplicate the consumption (required)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun idempotencyKey(): String = idempotencyKey.getRequired("idempotencyKey")
+
+ /**
+ * Optional timestamp the consumption is attributed to
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun createdAt(): Optional = createdAt.getOptional("createdAt")
+
+ /**
+ * Optional dimensions describing the consumption
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun dimensions(): Optional = dimensions.getOptional("dimensions")
+
+ /**
+ * Optional resource the consumption is attributed to
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun resourceId(): Optional = resourceId.getOptional("resourceId")
+
+ /**
+ * Returns the raw JSON value of [amount].
+ *
+ * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount
+
+ /**
+ * Returns the raw JSON value of [currencyId].
+ *
+ * Unlike [currencyId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("currencyId")
+ @ExcludeMissing
+ fun _currencyId(): JsonField = currencyId
+
+ /**
+ * Returns the raw JSON value of [customerId].
+ *
+ * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("customerId")
+ @ExcludeMissing
+ fun _customerId(): JsonField = customerId
+
+ /**
+ * Returns the raw JSON value of [idempotencyKey].
+ *
+ * Unlike [idempotencyKey], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("idempotencyKey")
+ @ExcludeMissing
+ fun _idempotencyKey(): JsonField = idempotencyKey
+
+ /**
+ * Returns the raw JSON value of [createdAt].
+ *
+ * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("createdAt")
+ @ExcludeMissing
+ fun _createdAt(): JsonField = createdAt
+
+ /**
+ * Returns the raw JSON value of [dimensions].
+ *
+ * Unlike [dimensions], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("dimensions")
+ @ExcludeMissing
+ fun _dimensions(): JsonField = dimensions
+
+ /**
+ * Returns the raw JSON value of [resourceId].
+ *
+ * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("resourceId")
+ @ExcludeMissing
+ fun _resourceId(): JsonField = resourceId
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Body].
+ *
+ * The following fields are required:
+ * ```java
+ * .amount()
+ * .currencyId()
+ * .customerId()
+ * .idempotencyKey()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Body]. */
+ class Builder internal constructor() {
+
+ private var amount: JsonField? = null
+ private var currencyId: JsonField? = null
+ private var customerId: JsonField? = null
+ private var idempotencyKey: JsonField? = null
+ private var createdAt: JsonField = JsonMissing.of()
+ private var dimensions: JsonField = JsonMissing.of()
+ private var resourceId: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(body: Body) = apply {
+ amount = body.amount
+ currencyId = body.currencyId
+ customerId = body.customerId
+ idempotencyKey = body.idempotencyKey
+ createdAt = body.createdAt
+ dimensions = body.dimensions
+ resourceId = body.resourceId
+ additionalProperties = body.additionalProperties.toMutableMap()
+ }
+
+ /** The amount of credits to consume */
+ fun amount(amount: Double) = amount(JsonField.of(amount))
+
+ /**
+ * Sets [Builder.amount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.amount] with a well-typed [Double] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun amount(amount: JsonField) = apply { this.amount = amount }
+
+ /** The credit currency to consume from (required) */
+ fun currencyId(currencyId: String) = currencyId(JsonField.of(currencyId))
+
+ /**
+ * Sets [Builder.currencyId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.currencyId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun currencyId(currencyId: JsonField) = apply { this.currencyId = currencyId }
+
+ /** The customer to consume credits from (required) */
+ fun customerId(customerId: String) = customerId(JsonField.of(customerId))
+
+ /**
+ * Sets [Builder.customerId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.customerId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun customerId(customerId: JsonField) = apply { this.customerId = customerId }
+
+ /** A unique key used to deduplicate the consumption (required) */
+ fun idempotencyKey(idempotencyKey: String) =
+ idempotencyKey(JsonField.of(idempotencyKey))
+
+ /**
+ * Sets [Builder.idempotencyKey] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.idempotencyKey] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun idempotencyKey(idempotencyKey: JsonField) = apply {
+ this.idempotencyKey = idempotencyKey
+ }
+
+ /** Optional timestamp the consumption is attributed to */
+ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))
+
+ /**
+ * Sets [Builder.createdAt] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun createdAt(createdAt: JsonField) = apply {
+ this.createdAt = createdAt
+ }
+
+ /** Optional dimensions describing the consumption */
+ fun dimensions(dimensions: Dimensions) = dimensions(JsonField.of(dimensions))
+
+ /**
+ * Sets [Builder.dimensions] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.dimensions] with a well-typed [Dimensions] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun dimensions(dimensions: JsonField) = apply {
+ this.dimensions = dimensions
+ }
+
+ /** Optional resource the consumption is attributed to */
+ fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId))
+
+ /**
+ * Sets [Builder.resourceId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.resourceId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun resourceId(resourceId: JsonField) = apply { this.resourceId = resourceId }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Body].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .amount()
+ * .currencyId()
+ * .customerId()
+ * .idempotencyKey()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Body =
+ Body(
+ checkRequired("amount", amount),
+ checkRequired("currencyId", currencyId),
+ checkRequired("customerId", customerId),
+ checkRequired("idempotencyKey", idempotencyKey),
+ createdAt,
+ dimensions,
+ resourceId,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StiggInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Body = apply {
+ if (validated) {
+ return@apply
+ }
+
+ amount()
+ currencyId()
+ customerId()
+ idempotencyKey()
+ createdAt()
+ dimensions().ifPresent { it.validate() }
+ resourceId()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StiggInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (amount.asKnown().isPresent) 1 else 0) +
+ (if (currencyId.asKnown().isPresent) 1 else 0) +
+ (if (customerId.asKnown().isPresent) 1 else 0) +
+ (if (idempotencyKey.asKnown().isPresent) 1 else 0) +
+ (if (createdAt.asKnown().isPresent) 1 else 0) +
+ (dimensions.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (resourceId.asKnown().isPresent) 1 else 0)
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Body &&
+ amount == other.amount &&
+ currencyId == other.currencyId &&
+ customerId == other.customerId &&
+ idempotencyKey == other.idempotencyKey &&
+ createdAt == other.createdAt &&
+ dimensions == other.dimensions &&
+ resourceId == other.resourceId &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ amount,
+ currencyId,
+ customerId,
+ idempotencyKey,
+ createdAt,
+ dimensions,
+ resourceId,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Body{amount=$amount, currencyId=$currencyId, customerId=$customerId, idempotencyKey=$idempotencyKey, createdAt=$createdAt, dimensions=$dimensions, resourceId=$resourceId, additionalProperties=$additionalProperties}"
+ }
+
+ /** Optional dimensions describing the consumption */
+ class Dimensions
+ @JsonCreator
+ private constructor(
+ @com.fasterxml.jackson.annotation.JsonValue
+ private val additionalProperties: Map
+ ) {
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map = additionalProperties
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /** Returns a mutable builder for constructing an instance of [Dimensions]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Dimensions]. */
+ class Builder internal constructor() {
+
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(dimensions: Dimensions) = apply {
+ additionalProperties = dimensions.additionalProperties.toMutableMap()
+ }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Dimensions].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Dimensions = Dimensions(additionalProperties.toImmutable())
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StiggInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Dimensions = apply {
+ if (validated) {
+ return@apply
+ }
+
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StiggInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Dimensions && additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() = "Dimensions{additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is ConsumptionConsumeParams &&
+ xAccountId == other.xAccountId &&
+ xEnvironmentId == other.xEnvironmentId &&
+ body == other.body &&
+ additionalHeaders == other.additionalHeaders &&
+ additionalQueryParams == other.additionalQueryParams
+ }
+
+ override fun hashCode(): Int =
+ Objects.hash(xAccountId, xEnvironmentId, body, additionalHeaders, additionalQueryParams)
+
+ override fun toString() =
+ "ConsumptionConsumeParams{xAccountId=$xAccountId, xEnvironmentId=$xEnvironmentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
+}
diff --git a/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeResponse.kt b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeResponse.kt
new file mode 100644
index 00000000..626842c4
--- /dev/null
+++ b/stigg-java-core/src/main/kotlin/io/stigg/models/v1/credits/consumption/ConsumptionConsumeResponse.kt
@@ -0,0 +1,967 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package io.stigg.models.v1.credits.consumption
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter
+import com.fasterxml.jackson.annotation.JsonAnySetter
+import com.fasterxml.jackson.annotation.JsonCreator
+import com.fasterxml.jackson.annotation.JsonProperty
+import io.stigg.core.ExcludeMissing
+import io.stigg.core.JsonField
+import io.stigg.core.JsonMissing
+import io.stigg.core.JsonValue
+import io.stigg.core.checkRequired
+import io.stigg.errors.StiggInvalidDataException
+import java.time.OffsetDateTime
+import java.util.Collections
+import java.util.Objects
+import java.util.Optional
+import kotlin.jvm.optionals.getOrNull
+
+/** Response object */
+class ConsumptionConsumeResponse
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val data: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of()
+ ) : this(data, mutableMapOf())
+
+ /**
+ * Result of a synchronous direct credit consumption
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is unexpectedly
+ * missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun data(): Data = data.getRequired("data")
+
+ /**
+ * Returns the raw JSON value of [data].
+ *
+ * Unlike [data], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [ConsumptionConsumeResponse].
+ *
+ * The following fields are required:
+ * ```java
+ * .data()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [ConsumptionConsumeResponse]. */
+ class Builder internal constructor() {
+
+ private var data: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(consumptionConsumeResponse: ConsumptionConsumeResponse) = apply {
+ data = consumptionConsumeResponse.data
+ additionalProperties = consumptionConsumeResponse.additionalProperties.toMutableMap()
+ }
+
+ /** Result of a synchronous direct credit consumption */
+ fun data(data: Data) = data(JsonField.of(data))
+
+ /**
+ * Sets [Builder.data] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.data] with a well-typed [Data] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun data(data: JsonField) = apply { this.data = data }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [ConsumptionConsumeResponse].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .data()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): ConsumptionConsumeResponse =
+ ConsumptionConsumeResponse(
+ checkRequired("data", data),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StiggInvalidDataException if any value type in this object doesn't match its expected
+ * type.
+ */
+ fun validate(): ConsumptionConsumeResponse = apply {
+ if (validated) {
+ return@apply
+ }
+
+ data().validate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StiggInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0)
+
+ /** Result of a synchronous direct credit consumption */
+ class Data
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val amount: JsonField,
+ private val currencyId: JsonField,
+ private val customerId: JsonField,
+ private val timestamp: JsonField,
+ private val credit: JsonField,
+ private val resourceId: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(),
+ @JsonProperty("currencyId")
+ @ExcludeMissing
+ currencyId: JsonField = JsonMissing.of(),
+ @JsonProperty("customerId")
+ @ExcludeMissing
+ customerId: JsonField = JsonMissing.of(),
+ @JsonProperty("timestamp")
+ @ExcludeMissing
+ timestamp: JsonField = JsonMissing.of(),
+ @JsonProperty("credit") @ExcludeMissing credit: JsonField = JsonMissing.of(),
+ @JsonProperty("resourceId")
+ @ExcludeMissing
+ resourceId: JsonField = JsonMissing.of(),
+ ) : this(amount, currencyId, customerId, timestamp, credit, resourceId, mutableMapOf())
+
+ /**
+ * The amount of credits consumed
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun amount(): Double = amount.getRequired("amount")
+
+ /**
+ * The credit currency the credits were consumed from
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun currencyId(): String = currencyId.getRequired("currencyId")
+
+ /**
+ * The customer the credits were consumed from
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun customerId(): String = customerId.getRequired("customerId")
+
+ /**
+ * The timestamp the consumption was attributed to
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
+ */
+ fun timestamp(): OffsetDateTime = timestamp.getRequired("timestamp")
+
+ /**
+ * The optimistic credit balance after consumption (when sync credit consumption is enabled)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun credit(): Optional = credit.getOptional("credit")
+
+ /**
+ * The resource the consumption was attributed to
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun resourceId(): Optional = resourceId.getOptional("resourceId")
+
+ /**
+ * Returns the raw JSON value of [amount].
+ *
+ * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount
+
+ /**
+ * Returns the raw JSON value of [currencyId].
+ *
+ * Unlike [currencyId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("currencyId")
+ @ExcludeMissing
+ fun _currencyId(): JsonField = currencyId
+
+ /**
+ * Returns the raw JSON value of [customerId].
+ *
+ * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("customerId")
+ @ExcludeMissing
+ fun _customerId(): JsonField = customerId
+
+ /**
+ * Returns the raw JSON value of [timestamp].
+ *
+ * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("timestamp")
+ @ExcludeMissing
+ fun _timestamp(): JsonField = timestamp
+
+ /**
+ * Returns the raw JSON value of [credit].
+ *
+ * Unlike [credit], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("credit") @ExcludeMissing fun _credit(): JsonField = credit
+
+ /**
+ * Returns the raw JSON value of [resourceId].
+ *
+ * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("resourceId")
+ @ExcludeMissing
+ fun _resourceId(): JsonField = resourceId
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Data].
+ *
+ * The following fields are required:
+ * ```java
+ * .amount()
+ * .currencyId()
+ * .customerId()
+ * .timestamp()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Data]. */
+ class Builder internal constructor() {
+
+ private var amount: JsonField? = null
+ private var currencyId: JsonField? = null
+ private var customerId: JsonField? = null
+ private var timestamp: JsonField? = null
+ private var credit: JsonField = JsonMissing.of()
+ private var resourceId: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(data: Data) = apply {
+ amount = data.amount
+ currencyId = data.currencyId
+ customerId = data.customerId
+ timestamp = data.timestamp
+ credit = data.credit
+ resourceId = data.resourceId
+ additionalProperties = data.additionalProperties.toMutableMap()
+ }
+
+ /** The amount of credits consumed */
+ fun amount(amount: Double) = amount(JsonField.of(amount))
+
+ /**
+ * Sets [Builder.amount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.amount] with a well-typed [Double] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun amount(amount: JsonField) = apply { this.amount = amount }
+
+ /** The credit currency the credits were consumed from */
+ fun currencyId(currencyId: String) = currencyId(JsonField.of(currencyId))
+
+ /**
+ * Sets [Builder.currencyId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.currencyId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun currencyId(currencyId: JsonField) = apply { this.currencyId = currencyId }
+
+ /** The customer the credits were consumed from */
+ fun customerId(customerId: String) = customerId(JsonField.of(customerId))
+
+ /**
+ * Sets [Builder.customerId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.customerId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun customerId(customerId: JsonField) = apply { this.customerId = customerId }
+
+ /** The timestamp the consumption was attributed to */
+ fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp))
+
+ /**
+ * Sets [Builder.timestamp] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.timestamp] with a well-typed [OffsetDateTime] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun timestamp(timestamp: JsonField) = apply {
+ this.timestamp = timestamp
+ }
+
+ /**
+ * The optimistic credit balance after consumption (when sync credit consumption is
+ * enabled)
+ */
+ fun credit(credit: Credit?) = credit(JsonField.ofNullable(credit))
+
+ /** Alias for calling [Builder.credit] with `credit.orElse(null)`. */
+ fun credit(credit: Optional) = credit(credit.getOrNull())
+
+ /**
+ * Sets [Builder.credit] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.credit] with a well-typed [Credit] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun credit(credit: JsonField) = apply { this.credit = credit }
+
+ /** The resource the consumption was attributed to */
+ fun resourceId(resourceId: String?) = resourceId(JsonField.ofNullable(resourceId))
+
+ /** Alias for calling [Builder.resourceId] with `resourceId.orElse(null)`. */
+ fun resourceId(resourceId: Optional) = resourceId(resourceId.getOrNull())
+
+ /**
+ * Sets [Builder.resourceId] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.resourceId] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun resourceId(resourceId: JsonField) = apply { this.resourceId = resourceId }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Data].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .amount()
+ * .currencyId()
+ * .customerId()
+ * .timestamp()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Data =
+ Data(
+ checkRequired("amount", amount),
+ checkRequired("currencyId", currencyId),
+ checkRequired("customerId", customerId),
+ checkRequired("timestamp", timestamp),
+ credit,
+ resourceId,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ /**
+ * Validates that the types of all values in this object match their expected types
+ * recursively.
+ *
+ * This method is _not_ forwards compatible with new types from the API for existing fields.
+ *
+ * @throws StiggInvalidDataException if any value type in this object doesn't match its
+ * expected type.
+ */
+ fun validate(): Data = apply {
+ if (validated) {
+ return@apply
+ }
+
+ amount()
+ currencyId()
+ customerId()
+ timestamp()
+ credit().ifPresent { it.validate() }
+ resourceId()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: StiggInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (amount.asKnown().isPresent) 1 else 0) +
+ (if (currencyId.asKnown().isPresent) 1 else 0) +
+ (if (customerId.asKnown().isPresent) 1 else 0) +
+ (if (timestamp.asKnown().isPresent) 1 else 0) +
+ (credit.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (resourceId.asKnown().isPresent) 1 else 0)
+
+ /**
+ * The optimistic credit balance after consumption (when sync credit consumption is enabled)
+ */
+ class Credit
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val currencyId: JsonField,
+ private val currentUsage: JsonField,
+ private val timestamp: JsonField,
+ private val usageLimit: JsonField,
+ private val usagePeriodEnd: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("currencyId")
+ @ExcludeMissing
+ currencyId: JsonField = JsonMissing.of(),
+ @JsonProperty("currentUsage")
+ @ExcludeMissing
+ currentUsage: JsonField = JsonMissing.of(),
+ @JsonProperty("timestamp")
+ @ExcludeMissing
+ timestamp: JsonField = JsonMissing.of(),
+ @JsonProperty("usageLimit")
+ @ExcludeMissing
+ usageLimit: JsonField = JsonMissing.of(),
+ @JsonProperty("usagePeriodEnd")
+ @ExcludeMissing
+ usagePeriodEnd: JsonField = JsonMissing.of(),
+ ) : this(
+ currencyId,
+ currentUsage,
+ timestamp,
+ usageLimit,
+ usagePeriodEnd,
+ mutableMapOf(),
+ )
+
+ /**
+ * The credit currency identifier
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun currencyId(): String = currencyId.getRequired("currencyId")
+
+ /**
+ * The credits consumed (optimistic — includes not-yet-reconciled usage)
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun currentUsage(): Double = currentUsage.getRequired("currentUsage")
+
+ /**
+ * The grant-version timestamp of this balance, used by the SDK for last-write-wins
+ * reconciliation
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun timestamp(): OffsetDateTime = timestamp.getRequired("timestamp")
+
+ /**
+ * The total credits granted
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun usageLimit(): Double = usageLimit.getRequired("usageLimit")
+
+ /**
+ * End of the current credit grant period (when recurring credits reset), if applicable
+ *
+ * @throws StiggInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun usagePeriodEnd(): Optional =
+ usagePeriodEnd.getOptional("usagePeriodEnd")
+
+ /**
+ * Returns the raw JSON value of [currencyId].
+ *
+ * Unlike [currencyId], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("currencyId")
+ @ExcludeMissing
+ fun _currencyId(): JsonField = currencyId
+
+ /**
+ * Returns the raw JSON value of [currentUsage].
+ *
+ * Unlike [currentUsage], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("currentUsage")
+ @ExcludeMissing
+ fun _currentUsage(): JsonField = currentUsage
+
+ /**
+ * Returns the raw JSON value of [timestamp].
+ *
+ * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("timestamp")
+ @ExcludeMissing
+ fun _timestamp(): JsonField = timestamp
+
+ /**
+ * Returns the raw JSON value of [usageLimit].
+ *
+ * Unlike [usageLimit], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("usageLimit")
+ @ExcludeMissing
+ fun _usageLimit(): JsonField = usageLimit
+
+ /**
+ * Returns the raw JSON value of [usagePeriodEnd].
+ *
+ * Unlike [usagePeriodEnd], this method doesn't throw if the JSON field has an
+ * unexpected type.
+ */
+ @JsonProperty("usagePeriodEnd")
+ @ExcludeMissing
+ fun _usagePeriodEnd(): JsonField = usagePeriodEnd
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Credit].
+ *
+ * The following fields are required:
+ * ```java
+ * .currencyId()
+ * .currentUsage()
+ * .timestamp()
+ * .usageLimit()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Credit]. */
+ class Builder internal constructor() {
+
+ private var currencyId: JsonField? = null
+ private var currentUsage: JsonField? = null
+ private var timestamp: JsonField? = null
+ private var usageLimit: JsonField